说明:如果使用soapui进行webservice测试时要求数据放置在<![CDATA[
和]]>
中间,但是如果传递的XML文件中也存在cdata,并且不做处理的话,会报错:com.ctc.wstx.exc.WstxParsingException: Unexpected close tag </ROWKEY>; expected </message>. at [row,col {unknown-source}]: [11,99]
,这是由于XML中cdata不允许嵌套导致的。错误示例如下:
对于如下
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="ws.dis.clinical.viewigh.com">
<soapenv:Header/>
<soapenv:Body>
<ws:req1>
<!--Optional:-->
<message>
<![CDATA[
<Root>
<ROWKEY><![CDATA[0026|1242010044162664X7|000303786200|2|2336747&3|1242010044162664X7.EMR]]></ROWKEY>
]]>
</Root>
</message>
</ws:operationRequest>
</soapenv:Body>
</soapenv:Envelope>
解决方案:
可以将message内容中CDATA里面的]]>
替换为]]]]><![CDATA[>
,替换后正确内容如下:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="ws.dis.clinical.viewigh.com">
<soapenv:Header/>
<soapenv:Body>
<ws:req1>
<!--Optional:-->
<message>
<![CDATA[
<Root>
<ROWKEY><![CDATA[0026|1242010044162664X7|000303786200|2|2336747&3|1242010044162664X7.EMR]]]]><![CDATA[></ROWKEY>
]]>
</Root>
</message>
</ws:operationRequest>
</soapenv:Body>
</soapenv:Envelope>