Python/Suds:找不到类型:'xs:complexType'

发布于 2024-08-03 07:33:04 字数 3160 浏览 10 评论 0原文

我有以下简单的 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

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

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 类 来修复架构,但作为SOAP 新手我不知道我的情况到底需要修复什么。这里有人有使用 Suds 修复/更正模式的经验吗?

I have the following simple python test script that uses Suds to call a SOAP web service (the service is written in 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):

<?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 class to 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

内心激荡 2024-08-10 07:33:04

Ewall的资源是一个很好的资源。如果您尝试在 suds trac 票证中搜索,您可能会发现其他人也遇到与您类似的问题 ,但具有不同的对象类型。这是学习示例以及它们如何导入名称空间的好方法。

问题是你的 wsdl 包含
引用的架构定义
(...) 但无法导入

http://schemas.xmlsoap.org/soap/encoding/"
命名空间(和相关的模式)
适当地。该架构可以在以下位置修补
使用模式 ImportDoctor 的运行时
正如这里所讨论的:
https://fedorahosted.org/suds/wiki/Documentation#FIXINGBROKENSCHEMAs

这是一个相当常见的问题。

常用引用的架构(即
未导入)
是 SOAP 第 5 节
编码模式。现在可以修复此问题
如下:

所有重点都是我的)。

您可以尝试使用这些文档提供的行来添加 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)

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

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.

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:

(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.

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文