August 2018
Intermediate to advanced
314 pages
8h 9m
English
Now, in order to send an asynchronous request using the reactive programming, we create an example of the JAX-RS client API. In the following code, we can see an example of the client API:
public class ClientAPI{ private static final String URL = "http://localhost:8080/asyncRestService/resources/upload"; private static final String FILE_PATH = "test.pdf"; public static void main( String[] args ) { Client client = ClientBuilder.newClient(); WebTarget target = client.target(URL); try { CompletionStage<String> csf = target.request() .rx() .post(Entity.entity(new FileInputStream(new File(FILE_PATH)),"application/pdf"),String.class); csf.whenCompleteAsync((path, err)->{ if( Objects.isNull( err ) ) System.out.println( ...
Read now
Unlock full access