[Fedora-suds-list] Help with Suds internal data structure representation of WSDL

Martin Aspeli optilude at gmail.com
Fri Apr 16 16:24:44 UTC 2010


Hi,

I've been working on a small package called wsdl2interface[1], which
uses Suds to parse a WSDL and spits out the Python code for a set of
interfaces (using zope.interface[2] and zope.schema[3]) that describe
the data types and service methods. This helps us write mocks for
remote services, allowing those mocks to be validated against the
schema, and underpins a micro-framework we have around Suds to make
web services pleasant to use in our project. It also makes for a
pretty readable "wsdl.py" that's usually the first point of call when
trying to understand how services hang together.

It's working pretty well for the two services we connect to (both, I
believe, written in Axis, and unfortunately I can't publicise their
WSDLs). However, for some other, public services, it's failing to come
up with the right return type.

What happens is that from our internal WSDL's, Suds finds two complex
types for each method: 'methodName' and 'methodNameResponse'. The
'methodName' object has one attribute for each parameter to the
method. The 'methodNameResponse' object has no attributes if the
method returns void, or a single attribute (usually, but not always
called 'response') if the method returns an actual value.

In the code generator, I look at the 'body.wrapped' attribute
(conjecture) and then look for the name of an output message. If the
output message has a name that matches a complex type with one
attribute, I use its type as the return type for the method, since
that's what Suds seems to return (i.e. I assume it's somehow
unwrapping the message).

However, with some services, e.g.
http://terraserver-usa.com/TerraService2.asmx?WSDL, there's no
'methodNameResponse' complex object, and so I can't figure out what
it's unwrapping and so what the "real" return type is going to be.
I've tried to find it something useful in the relevant data
structures, but I'm getting lost. Not being an expert on the WSDL spec
probably doesn't help. ;-)

The relevant code is here:
http://bitbucket.org/optilude/wsdl2interface/src/tip/wsdl2interface.py

Is there something obvious I could be doing better to get the right
return value?

It's messy and it has no tests, so sorry about that. It's largely
copied from pdb into the editor as I tried to understand Suds'
internal data structure. ;-)

Cheers,
Martin

[1] http://pypi.python.org/pypi/wsdl2interface
[2] http://pypi.python.org/pypi/zope.interface
[3] http://pypi.python.org/pypi/zope.schema


More information about the suds mailing list