16

最新バージョンのsuds(https://fedorahosted.org/suds/)を初めて使用していますが、ステップ1で停止します。

suds.TypeNotFound: Type not found: '(schema, http://www.w3.org/2001/XMLSchema, )'

今、私はこれがsudsの世界(https://fedorahosted.org/suds/wiki/TipsAndTricks#Schema-TypeNotFoundおよびPython / Suds:Type not found:'xs:complexType')で十分にカバーされていることを知っていますが、これは(a)スキーマはバージョン0.3.4以降に自動的にバインドされることになっているため、(b)回避策を明示的に使用しても、まだ機能しないため、わずかに異なります。

from suds.client import Client
from suds.xsd.sxbasic import Import

url = 'file:wsdl.wsdl'
Import.bind('http://schemas.xmlsoap.org/soap/encoding/')
client = Client(url, cache = None)

wsdlを使用:

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns="http://ws.client.com/Members.asmx"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
targetNamespace="http://ws.client.com/Members.asmx"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://ws.client.com/Members.asmx">

      <s:element name="GetCategoriesResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="GetCategoriesResult">
              <s:complexType>
                <s:sequence>
                  <s:element ref="s:schema" />
                  <s:any />
                </s:sequence>
              </s:complexType>
            </s:element>
          </s:sequence>
        </s:complexType>
      </s:element>

    </s:schema>
  </wsdl:types>
</wsdl:definitions>

上記の例外が発生します。

4

3 に答える 3

19

私はこれにしばらく頭を叩いていました。次の構文を使用して、最終的に問題を解決しました。

from suds.xsd.doctor import ImportDoctor, Import

url = 'http://somedomain.com/filename.php?wsdl'
imp = Import('http://schemas.xmlsoap.org/soap/encoding/')
imp.filter.add('http://some/namespace/A')
doctor = ImportDoctor(imp)

client = Client(url, doctor=doctor)

重要なのは、URLから始めることです。そのファイルをブラウザで開くと、wsdl定義が提供されます。ここに正しいURLが入力されていることと、XMLファイルが実際に開いていることを確認してください。URLの最後にある?wsdlにも注意してください。

次に、imp = Import('http://schemas.xmlsoap.org/soap/encoding/')標準のSOAPスキーマをインポートします。

第三に、imp.filter.add('http:somedomain.com/A')特定の名前空間を追加します。この名前空間の場所は、上記で定義したURLを開きurl=、セクションを探すことで見つけることができます<wsdl:import namespace="http://somedomain.com/A"

また、URLのhttpとhttpsにも注意してください。

于 2013-05-22T03:27:42.423 に答える
11

私たちはそれを機能させました、そしてそれが少し風変わりですが、あなたもそうしてくれたことを願っています。おそらく、明示的な場所またはフィルターが役立つでしょう。例えば:

imp = Import(
    'http://schemas.xmlsoap.org/soap/encoding/',
    location='http://schemas.xmlsoap.org/soap/encoding/'
)
imp.filter.add('http://ws.client.com/Members.asmx')
client = Client(url, plugins=[ImportDoctor(imp)])
于 2011-05-11T18:59:41.827 に答える
7

まだこの問題に悩んでいる人のために。このリンクhttps://bitbucket.org/jurko/suds/issue/20/typenotfound-schemaは、有用な情報を提供する場合があります。解決策は次のようになります。

from suds.client import Client
from suds.xsd.doctor import Import, ImportDoctor

url = 'http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl'
imp = Import('http://www.w3.org/2001/XMLSchema',
    location='http://www.w3.org/2001/XMLSchema.xsd')
imp.filter.add('http://WebXml.com.cn/')
client = Client(url, doctor=ImportDoctor(imp))
于 2015-04-10T06:02:43.303 に答える