聽起來像是你有一個破碎的WSDL。這是您需要使用SUDS提供的ImportDoctor
的地方。您需要使用它來幫助Client
構造函數使用在http://schemas.microsoft.com/2003/10/Serialization/Arrays
處找到的ArrayOfint
類型。
我已經在過去與其他服務,但沒有看到您的WSDL或代碼做到了這一點,這僅僅是我的最好的,因爲你會如何解決它,因爲我不能測試它自己的猜測:
from suds.client import Client
from suds.xsd.doctor import Import, ImportDoctor
# Obviously I made this up
wsdl_url = 'http://whatever/path/to/wsdl'
# Fix missing types with ImportDoctor
schema_url = 'http://schemas.microsoft.com/2003/10/Serialization/Arrays'
schema_import = Import(schema_url)
schema_doctor = ImportDoctor(schema_import)
# Pass doctor to Client
client = Client(url=wsdl_url, doctor=schema_doctor)
有一點值得注意的是,URL http://schemas.microsoft.com/2003/10/Serialization/Arrays甚至沒有有效(它返回一個404),所以我真的不確定這是否是正確的URL。儘管我相信我至少在正確的方向上指導你。
編輯迴應你最近的評論(2010-10-05):
使用您所提供的https://developer-api.affili.net/V2.0/Logon.svc?wsdl
我是能夠成功地創建一個客戶端的URL。我不得不使用一個ImportDoctor
,因爲它提出了以下錯誤:
TypeNotFound: Type not found: '(Logon, http://affilinet.framework.webservices/types,)'
所以我用下面的代碼,並能夠獲得成功的客戶對象:
from suds.client import Client
from suds.xsd.doctor import Import, ImportDoctor
wsdl_url = 'https://developer-api.affili.net/V2.0/Logon.svc?wsdl'
schema_url = 'http://affilinet.framework.webservices/types'
schema_import = Import(schema_url)
schema_doctor = ImportDoctor(schema_import)
client = Client(url=wsdl_url, doctor=schema_doctor)
打印客戶端對象顯示此:
肥皂水(https://fedorahosted.org/suds/)版本:0.3.9 GA編譯:R659-20100219
Service (Authentication) tns="http://affilinet.framework.webservices/Svc"
Prefixes (5)
ns0 = "http://affilinet.framework.webservices/types"
ns1 = "http://schemas.datacontract.org/2004/07/Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF"
ns2 = "http://schemas.microsoft.com/2003/10/Serialization/"
ns3 = "http://schemas.microsoft.com/2003/10/Serialization/Arrays"
ns4 = "http://www.microsoft.com/practices/EnterpriseLibrary/2007/01/wcf/validation"
Ports (1):
(DefaultEndpointLogon)
Methods (2):
GetIdentifierExpiration(xs:string CredentialToken,)
Logon(xs:string Username, xs:string Password, ns0:WebServiceTypes WebServiceType, ns0:TokenDeveloperDetails DeveloperSettings, ns0:TokenApplicationDetails ApplicationSettings,)
Types (12):
ns3:ArrayOfKeyValueOfstringstring
ns1:ArrayOfValidationDetail
ns0:Logon
ns0:TokenApplicationDetails
ns0:TokenDeveloperDetails
ns1:ValidationDetail
ns4:ValidationFault
ns0:WebServiceTypes
ns0:affilinetWebserviceFault
ns2:char
ns2:duration
ns2:guid
在您使用client.service.Logon()
之前,您必須先滿足該方法所需的類型簽名。您必須使用client.factory.create()
(例如client.factory.create('ns0:WebServiceTypes')
)創建各種類型的對象,並將這些對象與您的用戶名/密碼一起傳遞。
重現問題的一些示例代碼可能會有幫助。 – 2010-09-21 14:00:06