1
错误我尝试了几个小时从Soap Webservice接收数据。python suds XML
这是我的代码:
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 = '[email protected]'
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>[email protected]</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>
我如何更新我的代码发送有效的请求?
在此先感谢
你的web服务器期望的例子当然不是一个有效的SOAP请求; SUDS只能发送WSDL指定的内容;如果SUDS产生的是错误的,那么服务器向你发送错误的WSDL。 – 2013-04-25 14:46:29
IIRC,在你初始化URL上的客户端之后做一个'打印客户端',**它将显示界面**,这个界面**是为你提供的Web服务。它可能与您的想法略有不同。我记得我不得不这样做,因为它只能正常工作:仅等待两个叶对象,在那里我给出了一个包含两个叶对象的对象。 – 2013-04-25 14:58:24