Python/Suds: Type not found: 'xs:complexType'
Asked Answered
B

1

10

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?

Brookins answered 25/8, 2009 at 15:53 Comment(3)
I just tried a simple C# test application and it can connect to this service fine (but then the service is ASP.net based). Could it be something Microsoft specific that Suds does not support by default?Brookins
It looks like the service is attempting to return a DataSet. I'm seeing the following in the logger: WARNING:suds.bindings.unmarshaller:attribute (IsDataSet) type, not-found WARNING:suds.bindings.unmarshaller:attribute (name) type, not-found ERROR:suds.bindings.unmarshaller:Schema:0x7fce048cBrookins
Sounds to me like SUDS isn't importing from an <import> tag that specifies the structure of the data set. Have you searched your WSDL for imports? If that's the answer, then SUDS' ImportDoctor should be able to help. Examples at fedorahosted.org/suds/wiki/Documentation#FIXINGBROKENSCHEMAsAruspex
D
14

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!

Duval answered 1/9, 2009 at 4:33 Comment(1)
I know it doesn't solve your problem entirely... but since you can't provide your wsdl, I can't try to figure out the exactly problem in this situation, so I tried to help you with some generic "blind debugging advice" to see if you could advance by yourself in the problem. But since you wrote this comment, I suppose you didn't find a solution to your problem... did you try the official Suds support?Duval

© 2022 - 2024 — McMap. All rights reserved.