Share an interface between client and server
43.2. Sharing an interface between client and server It is generally possible to share an interface between the client and server. In this scenario, you just have your JAX-RS services implement an annotated interface and then reuse that same interface to create client proxies to invoke on on the client-side. One caveat to this is when your JAX-RS methods return a Response object. The problem on the client is that the client does not have any type information with a raw Response return type declaration. There are two ways of getting around this. The first is to use the @ClientResponseType annotation. import org.jboss.resteasy.annotations.ClientResponseType; import javax.ws.rs.core.Response; @Path("/") public interface MyInterface { @GET @ClientResponseType(String.class) @Produces("text/plain") public Response get(); } This approach isn't always good enough. The problem is that some MessageBodyReaders and Writers need generic type information in order to match and service a request. @Path("/") public interface MyInterface { @GET @Produces("application/xml") public Response getMyListOfJAXBObjects(); } In this case, your client code can cast the returned Response object to a ClientResponse and use one of the typed getEntity() methods. MyInterface proxy = ProxyFactory.create(MyInterface.class, "http://localhost:8081"); ClientResponse response = (ClientResponse)proxy.getMyListOfJAXBObjects(); List list = response.getEntity(new GenericType>());