1

I set up a Client Proxy class with RESTEasy:

 ResourceIF resource = ProxyFactory.create(resourceIF.class, PATH, clientExecutor);

When I invoke

 ClientResponse res = (ClientResponse) resource.getObject();

for which my interface looks like this:

 @GET
 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
 public Response getObject()

I get automatically a XML representation. How to set it to JSON? Is it just about declaring a new only JSON aware Interface?

Robin Wieruch
  • 14,900
  • 10
  • 82
  • 107

1 Answers1

0

You have to add a MediaTypeInterceptor, something like this:

    ClientExecutor executor=ClientRequest.getDefaultExecutor();
    ResteasyProviderFactory factory=ResteasyProviderFactory.getInstance();
    InterceptorRegistry<ClientExecutionInterceptor> registry=factory.
        getClientExecutionInterceptorRegistry();
    registry.register(new MediaTypeInterceptor("application/json"));
    ResourceIF resource = ProxyFactory.create(ResourceIF.class,PATH,executor,factory);