【问题标题】:Problem Accessing WSDL-Service with python suds raises TypeNotFound: ArrayOfint使用 python suds 访问 WSDL 服务的问题引发 TypeNotFound:ArrayOfint
【发布时间】:2010-09-21 12:51:45
【问题描述】:

找不到类型:'(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, )'

【问题讨论】:

  • 一些重现问题的示例代码可能会有所帮助。

标签: python wsdl suds


【解决方案1】:

听起来您的 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)

打印客户端对象显示如下:

Suds (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'))创建各种类型的对象,并将这些对象与您的用户名/密码一起传递。

【讨论】:

  • wsdl_url = "developer-api.affili.net/V2.0/Logon.svc?wsdl" 我得到:错误:对输入进行标记时发生意外错误以下回溯可能已损坏或无效错误消息是:('EOF in multi-line statement', (9, 0)) 错误:对输入进行标记时发生意外错误以下回溯可能已损坏或无效错误消息为:('EOF in multi-line statement', (119, 0)) 错误:发生意外错误while tokenizing input 以下回溯可能已损坏或无效错误消息是:('EOF in multi-line statement', (141, 0))
猜你喜欢
  • 2016-10-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多