From: Pavel Bucek <Pavel.Bucek_at_Sun.COM>
Date: Mon, 08 Mar 2010 14:35:03 +0100
I was probably too brief and additionally didn't answered your question
from JAX-RS perspective.
there are two scenarios:
1) when passing JAXB object as a parameter to resource class method
When you specify plain JAXB class as a parameter, XML root element will
be discarded. JAXBElement can be used to access xml root element of
incoming message.
2) returning JAXB object from resource method
If you have class with @XmlRootElement annotation, xml root element will
be derived from that. If you don't, Jersey doesn't know how XML root
element should be constructed so you have to encapsulate your class in
JAXBElement instance, which will provide information needed to generate
xml root element (to be more concrete - you have to specify
javax.xml.namespace.QName of XML root element when creating JAXBElement
instance, see
http://java.sun.com/javase/6/docs/api/javax/xml/bind/JAXBElement.html).