[Twisted-Python] Raise soap faults

Eric Mangold teratorn at twistedmatrix.com
Fri Apr 15 13:39:48 EDT 2005

On Fri, 15 Apr 2005 11:39:03 -0500, Charles Moad <cmoad at indiana.edu> wrote:

> 	I have a soap server that I am trying to make handle errors correctly.
>  When there is an error I just return a SOAPpy.faultType instance.  The
> client should correspondlingly raise a python exception when it gets
> this.  Unfortunately it looks like twisted is returning the faultType
> instance as a valid response.  Here is the returned SOAP:

Yeah, I think that is right.

I believe you are supposed to raise an exception from your soap_* methods  
if you want a real SOAP fault to be returned. You may simply raise your  
faultType instance, or a faultType instance will be created automatically.

Though on the client side it still won't raise an exception, but you will  
hopefully get your faultType instance. You may check for it explicitly and  
raise it, if you like.

This behavior is probably wrong, and should be modified to be more in line  
with our other RPC implementations and SOAPpy itself. It would also be  
nice for Twisted to assert that the user isn't returning faultType  
instances from their soap_* methods, and if they are to advise them of the  
correct procedure.

Would you please open a bug on the tracker and assign it to me?  

Itamar, you're listed as the soap.py maintainer.. does this sound about  
right to you?


> *** Incoming SOAP ******************************************************
> <?xml version="1.0" encoding="UTF-8"?>
> <SOAP-ENV:Envelope
> SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
> <SOAP-ENV:Body>
> <pdbChainFileCompressedResponse SOAP-ENC:root="1">
> <SOAP-ENV:Fault SOAP-ENC:root="1">
> <faultcode>ArgumentError</faultcode>
> <faultstring>Invalid PDB Code</faultstring>
> </SOAP-ENV:Fault>
> </pdbChainFileCompressedResponse>
> </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
> ************************************************************************
> and the python result literally is:
> <SOAPpy.Types.structType Fault at -1213565780>: {'faultcode':
> 'ArgumentError', 'faultstring': 'Invalid PDB Code'}
> So the soappy client is treating this as a valid return value, and not
> raising an exception like it should.
> Any ideas?
> Thanks,
> 	Charlie
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

More information about the Twisted-Python mailing list