代码之家  ›  专栏  ›  技术社区  ›  Danielb

未找到python/suds:type:'xs:complexType'

  •  10
  • Danielb  · 技术社区  · 17 年前

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

    我需要用肥皂水 doctor class 要修复模式,但作为一个SOAP新手,我不知道在我的情况下究竟需要修复什么。这里有没有人有使用suds修复/更正模式的经验?

    1 回复  |  直到 17 年前
        1
  •  14
  •   GmonC    17 年前

    埃沃尔 的资源是很好的。如果你试图搜索suds-trac的票,你会发现其他人有问题。 similar to yours ,但对象类型不同。这是一个很好的方法,可以从中学习示例以及它们如何导入名称空间。

    问题是您的WSDL包含 引用的架构定义 (…)但无法导入 这个 “ http://schemas.xmlsoap.org/soap/encoding/ “ 命名空间(和关联架构) 适当地。可以在以下位置修补架构 使用架构importDoctor的运行时 如本文所述: https://fedorahosted.org/suds/wiki/Documentation#FIXINGBROKENSCHEMAs .

    这是一个相当普遍的问题。

    一种常用的模式 (那是 非进口) 肥皂区是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,我想您有理由不向我们展示……所以我认为你必须自己尝试这些可能性。祝你好运!