I'm building a middleware service that consumes external REST services (from the server side). I'm currently using Spring boot with RestTemplate to make the remote calls.
Map<String, String> urlVariables = new HashMap<>();
urlVariables.put("address", IP);
urlVariables.put("port", PORT);
urlVariables.put("par1", parameter1);
urlVariables.put("par2", parameter2);
MyServiceResponse state =
restTemplate.getForObject("http://{address}:{port}/service/{par1}/{par2}", MyServiceResponse.class, urlVariables);
I was wondering whether there's any library that provides annotations to automatically generate REST clients, like Volley does in Android.
@GET(url="http://{address}:{port}/service/{par1}/{par2}")
public MyServiceResponse getCurrentState(String address, String port, String par1, String par2)
There is the RESTEasy Proxy Framework:
Resteasy has a client proxy framework that allows you to use JAX-RS annotations to invoke on a remote HTTP resource. The way it works is that you write a Java interface and use JAX-RS annotations on methods and the interface.