2

找不到类型:“(ArrayOfint, http: //schemas.microsoft.com/2003/10/Serialization/Arrays,)”是 suds resolver 提出的。在 ...2003/10/Serialization/Arrays 中定义了 ArrayOfInt,所以我猜 linux 的区分大小写是问题所在。知道如何解决这个问题吗?

from suds.client import Client
c = Client("https://developer-api.affili.net/V2.0/Logon.svc?wsdl")

用于返回

Type not found: '(ArrayOfint, http://schemas.microsoft.com/2003/10/Serialization/Arrays, )'

现在几天以来,我什至不再去那里,而是得到了一个

TypeNotFound: Type not found: '(Logon, http://affilinet.framework.webservices/types, )'
4

1 回答 1

6

Sounds like you have a broken WSDL. This is where you'll need to use the ImportDoctor provided by SUDS. You need use this to help the Client constructor use the ArrayOfint type found at http://schemas.microsoft.com/2003/10/Serialization/Arrays.

I have done this in the past with other services but without seeing your WSDL or your code, this is only my best guess as to how you may fix it because I can't test it myself:

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)

One thing worth noting is that the URL http://schemas.microsoft.com/2003/10/Serialization/Arrays is not even valid (it returns a 404), so I am really not sure that is the right URL. Although I am confident that I am at least steering you in the right direction.

Edit in response to your recent comment (2010-10-05):

Using the URL you provided of https://developer-api.affili.net/V2.0/Logon.svc?wsdl I was able to successfully create a client. I had to use an ImportDoctor because it raised the following error:

TypeNotFound: Type not found: '(Logon, http://affilinet.framework.webservices/types, )'

So I used the following code and was able to get a successful client object:

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)

Printing the client object displays this:

Suds ( https://fedorahosted.org/suds/ ) version: 0.3.9 GA build: 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

Before you can use client.service.Logon() you're going to have to satisfy the type signature required by that method. You'll have to create various type objects using client.factory.create() (e.g. client.factory.create('ns0:WebServiceTypes')) and pass those objects along with your username/password.

于 2010-09-21T14:53:46.843 回答