Is there a way to use JAX-RS annotated interface with Jersey as the client?
This link seems to be more practical: http://blog.alutam.com/2012/05/04/proxy-client-on-top-of-jax-rs-2-0-client-api/
// configure Jersey client
ClientConfig cc = new ClientConfig().register(JacksonFeature.class)
.register(AnotherFeature.class)
.register(SomeFilter.class);
Client resource = ClientBuilder.newClient(cc);
// create client proxy
ServiceInterface proxy = WebResourceFactory.newResource(ServiceInterface.class,
resource.target(ServiceURI));
// invoke service
MyType result = proxy.someMethod();
For maven project you would need following dependencies:
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-proxy-client</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey.version}</version>
</dependency>
After some further googling I found that the answer is, provided you are using jersey 2.0, to use the jersey proxy-client module which can be found here: -
https://jersey.java.net/project-info/2.0/jersey/project/jersey-proxy-client/dependencies.html