我花了几个小时从Soap web服务接收数据。在
这是我的代码:
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()
这是我发送的:
^{pr2}$这就是Web服务器所期望的:
<?xml version="1.0" encoding="UTF-8"?>
<GATEWAY xmlns="urn:Software-com:Gateway:v7-00">
<CustomerService>
<checkIfExists>
<SessionID/>
<UserID>test</UserID>
</checkIfExists>
</CustomerService>
</GATEWAY>
如何更新代码以发送有效请求?在
提前谢谢
您可以实现一个Suds插件来在发送XML之前修改它。在
在下面的示例中,
<SOAP-ENV:Envelope>
标记被修改以符合Web服务器的期望:您必须完成
marshalled
方法来完全转换XML。但在执行此操作之前,请检查您是否有正确的WSDL文件,如@Martijn Pieters所说。在相关问题 更多 >
编程相关推荐