soapUI (或curl等工具) 测试 webservice,参数带有 xml 的处理

soapUI是我们常用的一种测试webservice的工具。

如果我们的参数是为xml

如下:

<root>
	<id>1</id>
	<name>Mike</name>
</root>

的话,soapUI解析的时会将<root>类型的以为是节点,导致参数无法正确传递

解决方法:

在xml外包装一层 <![CDATA[      xml内容...    ]]>

如上述的xml则为

<![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<root>
	<id>1</id>
	<name>Mike</name>
</root>]]>

同理,curl 中参数如果带有xml,也需要加上转义,调用webservice的例子,如下:

curl -H 'Content-Type:text/xml;charset=utf-8' -d '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pub="http://publish.service.boco.com/"><soapenv:Header/><soapenv:Body><pub:call><reqData><![CDATA[<wsParam><code>WS_WIRELESS_CODE</code></wsParam>]]></reqData></pub:call></soapenv:Body></soapenv:Envelope>' http://restar.gmcc.net:9044/ws/common?wsdl
发布了69 篇原创文章 · 获赞 72 · 访问量 24万+

猜你喜欢

转载自blog.csdn.net/londa/article/details/97932828
今日推荐