Simplest Possible REST Client 📎
To access the Simplest Possible REST Endpoint from Java, you will have to implement some code:
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
final String URI = "http://localhost:8080/hello-rest/resources/message";
//...
Client client = ClientBuilder.newClient();
String result = client.target(URI).
request().
get(String.class);
assertThat(result, containsString("duke"));
For server-to-server communication no additional dependency is required. If you are using the client as test driver, you will have to declare the dependency to the SPI of you choice e.g.
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.21</version>
</dependency>
See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.