Unmarshalling SOAP with JAXB leaves ANY-element empty (null)
I'm unmarshalling a SOAP-message with JAXB, and while most of the message looks fine when unmarshalled, one element is null when its content should be plain text. If I change its content to xml (e.g. <Test> Something </test>
, it works fine.
I beleive the schema describing this part is the following:
<xsd:complexType name="NotificationMessageHolderType" >
<xsd:sequence>
开发者_Go百科 <xsd:element name="Topic"
type="wsnt:TopicExpressionType"
minOccurs="1" maxOccurs="1" />
<xsd:element name="ProducerReference"
type="wsa:EndpointReferenceType"
minOccurs="1" maxOccurs="1" />
<xsd:element name="Message" type="xsd:anyType"
minOccurs="1" maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
The problem is with the LAST element in this schema, the Message element. Its type is "xsd:anyType", doesn't that mean it could hold anything? But when unmarshalling with JAXB, any non-structured content (verbatim text) seems to get omitted.
Does anybody know why, and what I might do to remedy the situation?
Regards, Eflite
This page(note, wayback machine archived item) is the best place to look for the answer; it provides a clear example on how to address your scenario.
I am quoting from there: "If you need to marshal arbitrary content you'll have to create a content tree according to org.w3c.dom. Sun's JAXB currently uses the implementation from Apache's Xerces, i.e., class apache.xerces.internal.dom.ElementNSImpl."
精彩评论