Can JAX-B include an XML-valued attribute verbatim?
I have an object which is the return value for a web service method. One of its properties contains an XML document. Ideally, I'd like to have JAX-B include that XML document verbatim in the web service response, rather than escaping everything or having to unmarshal it just to allow the webservice开发者_如何转开发 mapping to marshal it again immediately.
Can this be done via annotations or a custom binding definition?
EDIT: The reason I want to do this is that the XML document is retrieved from an Oracle DB (column type XmlType), and I generally want to avoid unnecessary parsing/formatting steps in getting it out to the webservice client.
I think you'll have to convert the XML string into a org.w3c.dom.Element
object first, add that to your model, and annotate it with @XmlAnyElement
. JAXB will then serialize that as verbatim XML (schema validation not withstanding).
精彩评论