title: How to get the response header in a RestEasy client?
body: <p>i´m implementing a Restful service using Jax-RS 2.0 (<a href="http://docs.jboss.org/resteasy/docs/3.0.7.Final/userguide/html_single/index.html" rel="nofollow">Resteasy 3.0.7.Final</a>) and share the interface between client and service.</p>
  
  <p>The return value is void because ClientResponse is deprecated since RestEasy introduced JAX-RS 2.0 in version 3+.</p>
  
  <p>To return the location of the new created object i inject the response, using the <code>@Context</code> annotation, and add the Content-Location header.</p>
  
  <p>For example:</p>
  
  <p>Shared Interface:</p>
  
  <pre><code>   @Path("/")
     @Consumes("application/xml")
     @Produces("application/xml")
     interface Resource {
  
          @Path("createSomething")
          void createSomething(AnyObject object);
  
          ...
     }
  </code></pre>
  
  <p>Implementation class (The Service):</p>
  
  <pre><code>    class ResourceImpl {
  
           ...
           @Context org.jboss.resteasy.spi.HttpResponse response;
           ...
  
           @Override
           void createSomething(AnyObject object) throws AnyException {
  
               String id = service.create(object);
  
               response.getOutputHeaders().putSingle("Content-Location",
                    "/createSomething/" + id);
  
               response.setStatus(Response.Status.CREATED.getStatusCode());
           }
  
      }
  </code></pre>
  
  <p>The client (build with the Resteasy Proxy Framework):</p>
  
  <pre><code>     ...
       ResteasyClient client = new ResteasyClientBuilder().build();
       ResteasyWebTarget target = client.target(baseUrl);
  
       Resource resource = (Resource) target.proxy(Resource.class);   
  
       resource.createSomething(anyObject);
       ...
  </code></pre>
  
  <p>How can i retrieve Header information (and others, like Atom Links) which has been  injected by the service?</p>
  
  <p>Is it reasonable to use client side Filters and Interceptors?</p>
  
  <p>Thank You</p>