如何防止字符串参数被解析为xml?
<s:element name="MyResponse">
<s:complexType>
<s:sequence>
<s:element type="s:string" name="xmlResultWithStringType" minOccurs="0" maxOccurs="1" />
</s:sequence>
</s:complexType>
</s:element>
在日志中我有一个正确的答案 -
Hello xmlStart <foo>in foo<bar>in bar</bar> end foo</foo> xmlEnd
完整日志:
---[HTTP request - http://localhost:8080/mockXXX]---
Accept: application/soap+xml, multipart/related
Content-Type: application/soap+xml; charset=utf-8;action="http://xxx"
User-Agent: JAX-WS RI 2.2.7-b01 svn-revision#13316
<?xml version="1.0" ?><S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope"><S:Body><MyRequest xmlns="http://fff"><xmlRequest>req do webserwisu</xmlRequest></MyRequest></S:Body></S:Envelope>--------------------
---[HTTP response - http://localhost:8080/mockXXX - 200]---
null: HTTP/1.1 200 OK
Content-Type: application/soap+xml;charset=UTF-8
Server: Jetty(6.1.x)
Transfer-Encoding: chunked
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:fff="http://fff">
<soap:Header/>
<soap:Body>
<fff:MyResponse>
<!--Optional:-->
<fff:XmlResultWithStringType>Hello xmlStart <foo>in foo<bar>in bar</bar> end foo</foo> xmlEnd</fff:XmlResultWithStringType>
</fff:MyResponse>
</soap:Body>
</soap:Envelope>--------------------
但是,webservice调用仅返回 的 xmlEnd2 整个开头都丢失了,XmlResultWithStringType的内容由xml解析器解析, 但它不应该, 如何防止它被解析? 我使用jax-ws-RI实现,
答案 0 :(得分:0)
它应该是CDATA部分
<![CDATA[ any xml possible here, it won't be treated as xml but as string ]]>
否则,如果没有CDATA,则将其视为xml而不是字符串。