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