Linux中用curl命令调用webservice接口

924 阅读1分钟

如下范例:

curl -H 'content-type:text/xml;charset=utf-8' -H 'SOAPAction:""' -d '<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:xsi="<http://www.w3.org/2001/XMLSchema-instance>" xmlns:xsd="<http://www.w3.org/2001/XMLSchema>" xmlns:soapenv="<http://schemas.xmlsoap.org/soap/envelope/>" xmlns:call="[http://call.gtms.module.ailk.com](http://call.gtms.module.ailk.com/)">   <soapenv:Header/>   <soapenv:Body>      <call:call soapenv:encodingStyle="<http://schemas.xmlsoap.org/soap/encoding/>">          <param xsi:type="soapenc:string" xmlns:soapenc="<http://schemas.xmlsoap.org/soap/encoding/>"><![CDATA[<root>               <cmdId>FromGK-202007171506376662</cmdId>               <authUser>iptv</authUser>               <authPwd>123</authPwd>               <servTypeId>25</servTypeId>               <operateId>23</operateId>               <param>                  <address>测试地址</address>                  <servaccount>073400692171A@tv</servaccount>                   <mac>F44C70F8DDA3</mac>                  <grid>2588</grid>                  <opertor>300461</opertor>               </param>            </root>]]></param>      </call:call>   </soapenv:Body></soapenv:Envelope>' http://10.62.166.72:8001/iptv/services/GtmsAxis

说明:

Image.png

返回结果可能是Html转义的,需要经过html反转义

<?xml version="1.0" encoding="UTF-8"?><root><sheeted>202007171152444540</sheeted><resultCode>102</resultCode><resultDes>调用方IP非法!</resultDes></root>

html反转义网站:

www.toolnb.com/tools/htmle…

转义效果:

Image.png