tags:

views:

1580

answers:

1

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/"&gt;

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?

+4  A: 

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!

GmonC
I can't seem to accept this as the answer for some reason :(
Danielb
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?
GmonC