English 中文(简体)
can a valid xml body have escaped characters for the < and > around the element names
原标题:

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>
&lt;Foo&gt;bar&lt;/Foo&gt;
    </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





相关问题
how to represent it in dtd?

I have two element action and guid. guid is a required field when action is add. but when action is del it will not appear in file. How to represent this in dtd ?

.Net application configuration add xml-data

I need to add xml-content to my application configuration file. Is there a way to add it directly to the appSettings section or do I need to implement a configSection? Is it possible to add the xml ...

XStream serializing collections

I have a class structure that I would like to serialize with Xstream. The root class contains a collection of other objects (of varying types). I would like to only serialize part of the objects that ...

MS Word splits words in its XML format

I have a Word 2003 document saved as a XML in WordProcessingML format. It contains few placeholders which will be dynamically replaced by an appropriate content. But, the problem is that Word ...

Merging an XML file with a list of changes

I have two XML files that are generated by another application I have no control over. The first is a settings file, and the second is a list of changes that should be applied to the first. Main ...

How do I check if a node has no siblings?

I have a org.w3c.dom.Node object. I would like to see if it has any other siblings. Here s what I have tried: Node sibling = node.getNextSibling(); if(sibling == null) return true; else ...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

热门标签