16

I'm using the latest version of suds (https://fedorahosted.org/suds/) for the first time and I'm getting stalled at step one.

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

Now, I know this is well covered ground in the suds world (https://fedorahosted.org/suds/wiki/TipsAndTricks#Schema-TypeNotFound and Python/Suds: Type not found: 'xs:complexType') but this appears to slightly different because (a) schema is supposed to be automatically bound after version 0.3.4 and (b) even explicitly using the workaround, it still doesn't work.

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)

with the 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>

yields the exception above.

Community
  • 1
  • 1
dpjanes
  • 5,745
  • 3
  • 25
  • 30

3 Answers3

19

I was banging my head for a while on this one. I finally resolved the issue by using the following syntax:

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)

Importantly, start with the url. Open that file in your browser and it will provide you with the wsdl definitions. Make sure you have the right url entered here and that an XML file actually opens. Also mind the ?wsdl at the end of the url.

Second, imp = Import('http://schemas.xmlsoap.org/soap/encoding/') will import the standard SOAP schema.

Third, imp.filter.add('http:somedomain.com/A') will add your specific namespace. You can find this namespace location by opening the url you defined above in url=and looking for the section <wsdl:import namespace="http://somedomain.com/A".

Also be mindful of http vs https in your urls.

shabeer90
  • 5,161
  • 4
  • 47
  • 65
tandy
  • 1,931
  • 4
  • 24
  • 28
  • 1
    +1 for the reference to the namespace-url, this is actually quite important, as you could easily reuse the wsdl-url there, which will do nothing – asdfsdfsdfsdfsd3232 Jun 19 '13 at 13:25
  • Is this applicable to a problem I am facing https://stackoverflow.com/questions/44586989/not-able-to-create-a-soap-filter-in-suds ? – Hussain Jun 24 '17 at 08:43
  • And what do you use if your XML does not have the ``? As mine does not. – elPastor Mar 13 '18 at 00:12
11

We got it working and I hope you did as well, even though it is a bit quirky. Perhaps an explicit location or filter will help. E.g.:

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)])
M.javid
  • 6,387
  • 3
  • 41
  • 56
Peter Lundberg
  • 180
  • 2
  • 5
  • Thank you for the answer and I'm sure it will help future people who come across this issue. Alas, I decided to just talk XML to the interface which is ugly but surprisingly undifficult to do. – dpjanes May 13 '11 at 22:07
  • @dpjanes: Indeed it did. Only took two days to get this blasted thing to work. – Ulrich Schwarz Aug 02 '11 at 10:16
  • 1
    This doesn't seem to have any affect at all for me. I get the exact same error described above before and after doing the import. I am using the latest suds 0.4 – ThatAintWorking Sep 05 '13 at 21:12
  • Does this apply to my problem https://stackoverflow.com/questions/44586989/not-able-to-create-a-soap-filter-in-suds – Hussain Jun 23 '17 at 07:13
7

For those who still is troubled by this problem. This link https://bitbucket.org/jurko/suds/issue/20/typenotfound-schema may provide useful information. The solution would be like this:

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))
ljk321
  • 16,242
  • 7
  • 48
  • 60