RestfulClient

Setup the Restful Client with Basic-Auth:Make a Request and then digest the Response:

For example:

val clientConfig = RestfulClientConfig.builder();
    .restfulBaseUrl("http://localhost:8080/helloworld/restful/")
        .authenticationMode(AuthenticationMode.BASIC)
        .basicAuthUser("sven")
        .basicAuthPassword("pass")
.useRequestDebugLogging(true) // default = false
.build();

RestfulClient client = RestfulClient.ofConfig(clientConfig);
 _Builder request = client.request("services/myService/actions/lookupMyObjectById/invoke")
    .accept(RestfulClientMediaType.SIMPLE_JSON.mediaTypeFor(MyObject.class, EnumSet.of(SuppressionType.RO)));

Entity args = client.arguments()
        .addActionParameter("id", "12345")
        .build();

Response response = request.post(args);

Try digest = client.digest(response, MyObject.class);_

if(digest.isSuccess()) {
    System.out.println("result: "+ digest.getValue().orElseThrow().get$$instanceId());
} else {
    digest.getFailure().get().printStackTrace();
}

API

RestfulClient.java
class RestfulClient {
  RestfulClient ofConfig(RestfulClientConfig clientConfig)     (1)
  RestfulClient ofConfig(RestfulClientConfig clientConfig, AuthorizationHeaderFactory authorizationHeaderFactory)     (2)
  RestfulClient ofConfig(RestfulClientConfig clientConfig, UnaryOperator<ClientBuilder> configRefiner)
  RestfulClient ofConfig(RestfulClientConfig clientConfig, UnaryOperator<ClientBuilder> configRefiner, AuthorizationHeaderFactory authorizationHeaderFactory)
  RestfulClientConfig getConfig()
  Client getJaxRsClient()
  void close()
  Builder request(String path)
  ActionParameterListBuilder arguments()
  Try<T> digest(Response response, Class<T> entityType)
  Try<Can<T>> digestList(Response response, Class<T> entityType, GenericType<List<T>> genericType)
  Try<T> digestValue(Response response, ValueSemanticsProvider<T> valSemantics)     (3)
  URI uri(String path)     (4)
}
1 ofConfig(RestfulClientConfig)
2 ofConfig(RestfulClientConfig, AuthorizationHeaderFactory)
3 digestValue(Response, ValueSemanticsProvider)

For transport of ValueDecomposition over REST.

4 uri(String)

Returns an URI constructed from this client’s base path plus given relative path .

Members

ofConfig(RestfulClientConfig)

ofConfig(RestfulClientConfig, AuthorizationHeaderFactory)

digestValue(Response, ValueSemanticsProvider)

For transport of ValueDecomposition over REST.

uri(String)

Returns an URI constructed from this client’s base path plus given relative path .