gpt4 book ai didi

python - 使用 python suds 访问 WSDL 服务时出现问题引发 TypeNotFound : ArrayOfint

转载 作者:行者123 更新时间:2023-11-28 21:30:04 24 4
gpt4 key购买 nike

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

最佳答案

听起来您的 WSDL 有问题。这是您需要使用 ImportDoctor 的地方由 SUDS 提供。您需要使用它来帮助 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'))创建各种类型的对象并传递这些对象连同您的用户名/密码。

关于python - 使用 python suds 访问 WSDL 服务时出现问题引发 TypeNotFound : ArrayOfint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3760427/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com