在项目对接中需要从对方服务器获取数据,对方提供的是标准的webservice接口。
通过fiddler抓包发现,webservice其实是post请求加上data.xml数据,所以使用curl post请求模拟webservice
curl -request POST --header "SOAPAction: ''" --data @data.xml http://ip:8080/project/services/DocumentService?wsdl
data.xml就是请求的数据信息,包括请求的方法、参数信息。data.xml数据是来源于fiddler抓包。
将信息复制出来保存为data.xml
<?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>
<getDocumentById soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<passportXml xsi:type="xsd:string">
<![CDATA[
<passport><username>swbgt</username><password>0123456789</password></passport>
]]>
</passportXml>
<id xsi:type="xsd:string">22ecaf63eda34d3bb4212b01bc32f332</id>
</getDocumentById>
</soapenv:Body>
</soapenv:Envelope>
最后模拟请求成功