Python/Suds:找不到类型:'xs:complexType'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1329190/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python/Suds: Type not found: 'xs:complexType'
提问by Danielb
I have the following simple python test script that uses Sudsto call a SOAP web service (the service is written in ASP.net):
我有以下简单的 python 测试脚本,它使用Suds调用 SOAP Web 服务(该服务是用 ASP.net 编写的):
from suds.client import Client
url = 'http://someURL.asmx?WSDL'
client = Client( url )
result = client.service.GetPackageDetails( "MyPackage" )
print result
When I run this test script I am getting the following error (used code markup as it doesn't wrap):
当我运行这个测试脚本时,我收到以下错误(使用了代码标记,因为它没有换行):
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'
Looking at the source for the WSDL file's header (reformatted to fit):
查看 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/">
I am guessing based on the last line of output:
我猜测基于最后一行输出:
suds.TypeNotFound: Type not found: 'xs:complexType'
That I need to use Sud's doctor classto fix the schema but being a SOAP newbie I don't know what exactly needs fixed in my case. Does anyone here have any experience using Suds to fix/correct schema?
我需要使用 Sud 的医生课程来修复架构,但作为 SOAP 新手,我不知道在我的情况下究竟需要修复什么。这里有人有使用 Suds 修复/纠正架构的经验吗?
回答by GmonC
Ewall's resource is a good one. If you try to search in suds trac tickets, you could see that other people have problems similar to yours, but with different object types. It can be a good way to learn from it's examples and how they import their namespaces.
Ewall的资源是一个很好的资源。如果您尝试在 suds trac 票证中进行搜索,您会发现其他人遇到了与您类似的问题,但对象类型不同。从它的示例中学习它们如何导入命名空间是一种很好的方式。
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 包含引用 (...) 的架构定义,但未能正确导入“ http://schemas.xmlsoap.org/soap/encoding/”命名空间(和关联的架构)。可以在运行时使用模式 ImportDoctor 修补模式,如下所述:https://fedorahosted.org/suds/wiki/Documentation#FIXINGBROKENSCHEMAs 。
这是一个相当普遍的问题。
通常引用的模式(未导入)是 SOAP 第 5 节编码模式。这现在可以修复如下:
(all emphasis were mine).
(所有重点都是我的)。
You could try the lines that these documentations provide adding the namespaces presented in your WSDL. This can be a try-and-error aproach.
您可以尝试使用这些文档提供的行添加 WSDL 中显示的名称空间。这可以是一种试错法。
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)
You didn't provide the WSDL you're working with, I suppose you have reasons to not showing to us... so I think you have to try these possibilities by yourself. Good luck!
你没有提供你正在使用的 WSDL,我想你有理由不向我们展示......所以我认为你必须自己尝试这些可能性。祝你好运!