I have a management web application located on a remote server. This app was written using a MEAN stack and I have a list of all the RESTful routes necessary to connect to t
There are plenty of libraries to consume REST applications in Java nowadays.
The JAX-RS Client API (javax.ws.rs.client package), defined in the JSR 339, is the standard way to consume REST web services in Java. Besides others, this specification is implemented by Jersey and RESTEasy.
Both Jersey and RESTEasy APIs provide a proxy framework.
The basic idea is you can attach the standard JAX-RS annotations to an interface, and then implement that interface by a resource class on the server side while reusing the same interface on the client side by dynamically generating an implementation of that using java.lang.reflect.Proxy calling the right low-level client API methods.
For more details, check the following:
There are a few other good options you may consider as alternative to the JAX-RS Client API:
I would begin by reading the documentation for Jersey, specifically the Client portion. You will want to familiarize yourself with the WebTarget
class and it is invoked (example from the documentation):
ClientConfig clientConfig = new ClientConfig();
clientConfig.register(MyClientResponseFilter.class);
clientConfig.register(new AnotherClientFilter());
Client client = ClientBuilder.newClient(clientConfig);
client.register(ThirdClientFilter.class);
WebTarget webTarget = client.target("http://example.com/rest");
webTarget.register(FilterForExampleCom.class);
WebTarget resourceWebTarget = webTarget.path("resource");
WebTarget helloworldWebTarget = resourceWebTarget.path("helloworld");
WebTarget helloworldWebTargetWithQueryParam =
helloworldWebTarget.queryParam("greeting", "Hi World!");
Invocation.Builder invocationBuilder =
helloworldWebTargetWithQueryParam.request(MediaType.TEXT_PLAIN_TYPE);
invocationBuilder.header("some-header", "true");
Response response = invocationBuilder.get();
System.out.println(response.getStatus());
System.out.println(response.readEntity(String.class));