Root element name in collections returned by RESTEasy

隐身守侯 提交于 2019-12-01 02:38:48

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).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!