Reputation: 11
I have a JPA entity class mimicking a table. Something like this:
@XmlType(name="MyClassElementType")
public class MyClass {
String name;
String xmlDesc;
public MyClass() {}
@XmlElement
String getName() { return name; }
void setName(String name) { this.name = name; }
@XmlElement
String getXmlDesc() { return xmlDesc; }
void setXmlDesc(String xmlDesc) { this.xmlDesc = xmlDesc; }
}
In a Jersey REST get call I'm trying to return this class:
@Get
@Produces("application/xml")
public MyClass get() {
return myClass;
}
Now I'm expecting the already xml string(xmlStr) to be returned as is, but Jersey/JAXB escapes it...
So anyway around this?
Upvotes: 1
Views: 611
Reputation: 403581
JAXB has no way of knowing that xmlDesc
contains an XML string, it could be anything, so it has to escape it.
If you want to store arbitrary XML in a JAXB object model, you need to store it as an instance of org.w3c.dom.Element
. JAXB should then convert that to/from XML as necessary.
Upvotes: 3