users@jersey.java.net

[Jersey] JAXRS returning JAXB and HTTP headers at the same time

From: Graham Leggett <minfrin_at_sharp.fm>
Date: Thu, 17 Apr 2014 17:42:05 +0200

Hi all,

I have a fragment of wadl that looks like this:

        <response status="200">
          <representation mediaType="application/json" element="user:users"/>
          <representation mediaType="application/xml" element="user:users"/>
          <param name="ETag" style="header" type="xsd:string">
            <doc>The SHA1 hash of the sum of DN and modifiedTimestamp of the matching users.</doc>
          </param>
          <param name="Cache-Control" style="header" type="xsd:string">
            <doc>The Cache-Control header as specified through configuration in context.xml.</doc>
          </param>
          <param name="Vary" style="header" type="xsd:string">
            <doc>MUST have the value "Authorization", as we vary on the Authorization header.</doc>
          </param>
          <doc>Return list of users. Must have admin role to receive the response.
               Note: no users = empty list with status:200</doc>
        </response>

The response defines both a JAXB return type called "Users", as well as three HTTP headers, ETag, Cache-Control and Vary.

Is there a JAXRS compliant method signature that would allow me to return both the JAXB object and the headers at the same time?

Right now I understand I might use Users getUsers(…) and lose the ability to return the headers, or use Response getUsers() and lose the ability to return the JAXB object.

Is there something I am missing?

Regards,
Graham
--