I\'m using JAX-RS via RestEasy in JBoss AS 6. When my JAX-RS resource returns a collection of items (e.g. via a List), RESTEasy always uses the name collection
Appeared to be a case of RTFM: RestEasy docs - Arrays and Collections of JAXB Objects
So, if we wanted to output this XML
<foo:list xmlns:foo="http://foo.org"> <customer><name>bill</name></customer> <customer><name>monica</name></customer> </foo:list>
We would use the @Wrapped annotation as follows:
@GET @Path("list") @Produces("application/xml") @Wrapped(element="list", namespace="http://foo.org", prefix="foo") public List<Customer> getCustomerSet() { ... }
It's thus possible via the @Wrapped annotation. It's a RESTEasy specific one, but this will do for now.
Leaving the question open in case someone has an even better solution (still looking for a global interceptor orso that lets RESTEasy do what Jersey does).