[Fedora-suds-list] Handling faults from Axis web service

Martin Aspeli optilude at gmail.com
Tue Mar 30 16:03:13 UTC 2010


Hi,

I'm looking for a bit of clarity/expansion on the documentation for
handling of faults/exceptions in Suds.

We're connecting to a web service written in Axis. Right now, we only
have a WSDL file for this (which we're mocking up in SoapUI for test
purposes, though we also have an internal, Python-only mock of the
Suds service interface for unit testing purposes), i.e. we can't
connect to the service and test different responses just yet. We won't
be flying blind like this forever, but I want to make sure we don't
adopt a fundamentally wrong pattern until we get to the scheduled
integration testing.

The suds WebFault has two attributes: fault and document. It's not
quite clear to me what goes into these.

What I do know is that our WSDL has a complex type called
'SOAPException', which has an attribute 'message'. The developers of
the service are telling us that in certain error cases, they'll throw
an exception with an error code encoded into this 'message' attribute.
In an Axis client, that apparently throws an exception like this:

AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server
 faultSubcode:
 faultString: 213
 faultActor:
 faultNode:
 faultDetail:
      {http://acme.com/}SOAPException:<message>213</message>

The bit we're interested in is the 213. So, we have code like this:

try:
    response = client.service.someMethod()
except WebFault, e:
    # ?

The question is how we get at that 213 in the 'e' that's returned. My
guess was e.fault.message, but that's mostly conjecture.

Thanks,
Martin


More information about the suds mailing list