My web service is receiving xml from a third party that looks like this:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<Foo>bar</Foo>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
My开发者_如何学编程 jaxws web service rejects this with a parsing error. Also if I try to validate this xml using soapui it says Body with element-only content type cannot have text element.
My question is, is that xml valid? Or is the client supposed to send me something without escaping the < and >.
Any references to xml standards or rules are appreciated.
Well, that's certainly valid XML. However your question seems to be rather whether it conforms to the SOAP protocol, which is a more restrictive question.
In the example, your SOAP body is just a text element. I'm no SOAP expert but in all of the SOAP examples I see, there are element nodes in the body and not just text. Also the SOAP Recommendation (http://www.w3.org/TR/2000/NOTE-SOAP-20000508) does say
"A body entry is identified by its fully qualified element name"
which does suggest a requirement for elements rather than text.
Alternatively, you may escape the full string by enclosing it with the CDATA (character data) section. A CDATA section begins with the nine-character delimiter ![CDATA[ and ends with the delimiter ]]:
<![CDATA["Me, Myself & <I>"]]>
take a look here http://xmmssc-www.star.le.ac.uk/SAS/xmmsas_20070308_1802/doc/param/node24.html
精彩评论