51Testing软件测试论坛

标题: SOAP/XML-RPC Request webservice接口测试报文尖括号<>转义问题 [打印本页]

作者: yanghamming    时间: 2015-5-5 17:03
标题: SOAP/XML-RPC Request webservice接口测试报文尖括号<>转义问题
---------------如何做到报文中,尖括号不用转义?

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:getDataInfo soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://webservice.dataservice.xxx.com/">
<arg0 xsi:type="xsd:string">
<USERINFOREQUEST>
    <MSGHEADER>
        <SESSIONID>AEC11168059SESS</SESSIONID>
        <USERNAME>zhangtian</USERNAME>
        <ASSWORD>e10adc3949ba59abbe56e057f20f883e</PASSWORD>
        <MSGTYPE>1</MSGTYPE>
        <VERSION>10</VERSION>
        <TIMETYPE>2</TIMETYPE>
        <NOTICE>1</NOTICE>
        <TRANSMISSION>2</TRANSMISSION>
    </MSGHEADER>
    <MSGBODY>
---------------------直接XML格式发送报错
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Fault occurred while processing.</faultstring></soap:Fault></soap:Body></soap:Envelope>



<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:getDataInfo soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://webservice.dataservice.xxx.com/">
<arg0 xsi:type="xsd:string">
<USERINFOREQUEST>
<MSGHEADER>
    <SESSIONID>AEC11128716SESS</SESSIONID>
    <USERNAME>zhangtian</USERNAME>
    <ASSWORD>e10adc3949ba59abbe56e057f20f883e</PASSWORD>
    <MSGTYPE>1</MSGTYPE>
    <VERSION>10</VERSION>
-------------------尖括号转义后,发送成功
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getDataInfoResponse xmlns:ns2="http://webservice.dataservice.xxx.com/"><return><?xml version="1.0" encoding="UTF-8" standalone="yes"?><USERINFORESPONSE><MSGHEADER><SESSIONID>AEC11128716SESS</SESSIONID><USERNAME>zhangtian</USERNAME><MSGTYPE>1</MSGTYPE><VERSION>10</VERSION><NOTICE>1</NOTICE><RESULTCODE>0000</RESULTCODE></MSGHEADER></USERINFORESPONSE></return></ns2:getDataInfoResponse></soap:Body></soap:Envelope>



作者: 土土的豆豆    时间: 2015-5-6 10:17
节点内容用CDATA段包起来试试,比如这样:<nondename><![CDATA[含有< >的内容]]></nodename>




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2