Created
April 3, 2016 07:56
-
-
Save abhirockzz/3b00c611d41968b2dd3bebfe0ab6c1f8 to your computer and use it in GitHub Desktop.
Synchronous invocation of a REST API using JAX-RS Client API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Response test() throws Exception{ | |
Client client = ClientBuilder.newBuilder().build(); | |
WebTarget target = client.target("http://localhost:8080/jaxrs-async-service/async"); | |
Invocation.Builder reqBuilder = target.request(); | |
Response response = reqBuilder.get(); //this will block until server responds or triggers out (even if its aysnc) | |
String responseBody = response.readEntity(String.class); | |
return Response.status(response.getStatus()).entity(responseBody).build(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment