gpt4 book ai didi

python /泡沫 : Type not found: 'xs:complexType'

转载 作者:太空狗 更新时间:2023-10-29 18:26:04 29 4
gpt4 key购买 nike

我有以下使用 Suds 的简单 python 测试脚本调用 SOAP 网络服务(该服务是用 ASP.net 编写的):

from suds.client import Client

url = 'http://someURL.asmx?WSDL'

client = Client( url )

result = client.service.GetPackageDetails( "MyPackage" )

print result

当我运行此测试脚本时出现以下错误(使用代码标记,因为它不换行):

No handlers could be found for logger "suds.bindings.unmarshaller"
Traceback (most recent call last):
File "sudsTest.py", line 9, in <module>
result = client.service.GetPackageDetails( "t3db" )
File "build/bdist.cygwin-1.5.25-i686/egg/suds/client.py", line 240, in __call__
File "build/bdist.cygwin-1.5.25-i686/egg/suds/client.py", line 379, in call
File "build/bdist.cygwin-1.5.25-i686/egg/suds/client.py", line 240, in __call__
File "build/bdist.cygwin-1.5.25-i686/egg/suds/client.py", line 422, in call
File "build/bdist.cygwin-1.5.25-i686/egg/suds/client.py", line 480, in invoke
File "build/bdist.cygwin-1.5.25-i686/egg/suds/client.py", line 505, in send
File "build/bdist.cygwin-1.5.25-i686/egg/suds/client.py", line 537, in succeeded
File "build/bdist.cygwin-1.5.25-i686/egg/suds/bindings/binding.py", line 149, in get_reply
File "build/bdist.cygwin-1.5.25-i686/egg/suds/bindings/unmarshaller.py", line 303, in process
File "build/bdist.cygwin-1.5.25-i686/egg/suds/bindings/unmarshaller.py", line 88, in process
File "build/bdist.cygwin-1.5.25-i686/egg/suds/bindings/unmarshaller.py", line 104, in append
File "build/bdist.cygwin-1.5.25-i686/egg/suds/bindings/unmarshaller.py", line 181, in append_children
File "build/bdist.cygwin-1.5.25-i686/egg/suds/bindings/unmarshaller.py", line 104, in append
File "build/bdist.cygwin-1.5.25-i686/egg/suds/bindings/unmarshaller.py", line 181, in append_children
File "build/bdist.cygwin-1.5.25-i686/egg/suds/bindings/unmarshaller.py", line 104, in append
File "build/bdist.cygwin-1.5.25-i686/egg/suds/bindings/unmarshaller.py", line 181, in append_children
File "build/bdist.cygwin-1.5.25-i686/egg/suds/bindings/unmarshaller.py", line 102, in append
File "build/bdist.cygwin-1.5.25-i686/egg/suds/bindings/unmarshaller.py", line 324, in start
suds.TypeNotFound: Type not found: 'xs:complexType'

查看 WSDL 文件头的来源(重新格式化以适合):

<?xml version="1.0" encoding="utf-8" ?> 
<wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://http://someInternalURL/webservices.asmx"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="http://someURL.asmx"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

我根据最后一行输出猜测:

suds.TypeNotFound: Type not found: 'xs:complexType'

我需要使用 Sud 的 doctor class修复架构,但作为 SOAP 新手,我不知道在我的案例中究竟需要修复什么。这里有人有使用 Suds 修复/更正架构的经验吗?

最佳答案

Ewall 的资源很好。如果您尝试在 suds trac 票中搜索,您会看到其他人有问题 similar to yours , 但具有不同的对象类型。这是从示例中学习以及它们如何导入命名空间的好方法。

The problem is that your wsdl contains a schema definition that references the (...) but fails to import the "http://schemas.xmlsoap.org/soap/encoding/" namespace (and associated schema) properly. The schema can be patched at runtime using the schema ImportDoctor as discussed here: https://fedorahosted.org/suds/wiki/Documentation#FIXINGBROKENSCHEMAs.

This is a fairly common problem.

A commonly referenced schema (that is not imported) is the SOAP section 5 encoding schema. This can now be fixed as follows:

(所有重点都是我的)。

您可以尝试使用这些文档提供的行来添加您的 WSDL 中提供的 namespace 。这可能是一种试错法。

imp = Import('http://schemas.xmlsoap.org/soap/encoding/')
# Below is your targetNamespace presented in WSDL. Remember
# that you can add more namespaces by appending more imp.filter.add
imp.filter.add('http://someURL.asmx')
doctor = ImportDoctor(imp)
client = Client(url, doctor=doctor)

您没有提供正在使用的 WSDL,我想您有理由不向我们展示...所以我认为您必须自己尝试这些可能性。祝你好运!

关于 python /泡沫 : Type not found: 'xs:complexType' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1329190/

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