我尝试了几个小时从 Soap Webservice 接收数据。
这是我的代码:
from suds.client import Client
from suds import WebFault
WSDL_URL = 'gatewaywebservice.asmx?wsdl'
client = Client(WSDL_URL)
checkIfExists = client.factory.create('checkIfExists')
checkIfExists.SessionID = ''
checkIfExists.UserID = 'ttester@email.com'
try:
response = client.service.CustomerService(checkIfExists)
#print response
if response.Error:
print response.Error
else:
pass
except WebFault, e:
print e
print client.last_sent()
print client.last_received()
这是我发送的:
<SOAP-ENV:Envelope xmlns:ns0="asdf" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns1:Body>
<ns0:CustomerService>
<ns0:CustomerService>
<ns0:SessionID></ns0:SessionID>
<ns0:UserID>ttester@email.com</ns0:UserID>
</ns0:CustomerService>
</ns0:CustomerService>
</ns1:Body>
</SOAP-ENV:Envelope>
这就是网络服务器所期望的:
<?xml version="1.0" encoding="UTF-8"?>
<GATEWAY xmlns="urn:Software-com:Gateway:v7-00">
<CustomerService>
<checkIfExists>
<SessionID/>
<UserID>test</UserID>
</checkIfExists>
</CustomerService>
</GATEWAY>
如何更新我的代码以发送有效请求?
提前致谢