[Fedora-suds-list] Dealing with exceptions from the web services

Jeff Ortel jortel at redhat.com
Thu May 27 13:48:42 UTC 2010



On 05/27/2010 08:21 AM, Donald W. Long wrote:
> more data.  Below is the log output from client
> DEBUG:suds.client:sending to (http://kwweb01:8080/SAWebService.asmx)
> message:
> <SOAP-ENV:Envelope
> xmlns:ns0="http://www.qualcomm.com/QCT/QSWAT/SAWebService"
> xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/
> " xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
> <SOAP-ENV:Header/>
> <ns1:Body>
> <ns0:GetBuildLocation>
> <ns0:BuildID></ns0:BuildID>
> </ns0:GetBuildLocation>
> </ns1:Body>
> </SOAP-ENV:Envelope>
> DEBUG:suds.client:headers = {'SOAPAction':
> u'"http://www.qualcomm.com/QCT/QSWAT/SAWebService/GetBuildLocation"',
> 'Content-Type': '
> text/xml'}
> DEBUG:suds.client:http succeeded:
> <?xml version="1.0" encoding="utf-8"?><soap:Envelope
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsi="http://www.
> w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Server</faultc
> <http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Server</faultc>
> ode><faultstring>Server was unable to process request. ---&gt; Build ID
> cannot be empty</faultstring><detail /></soap:Fault></soap
> :Body></soap:Envelope>
> When I look at the xml returned I sse the faultcode as soap:Server. Is
> this a correct web fault xml item? Also, how do I get to the
> <faultstring> area, if I can do this I could find out what the error is.

Yes, this appears to be a valid web fault.  If the server is not returning http code = 
500, you will need to use 0.4.  In 0.4, suds will raise an exception even if the http code 
= 200 if the <soap:Fault/> is present.  After you catch the exception, you can inspect to 
see what happened:

except WebFault f:
   print 'code=%s, string=%s' % (f.fault.faultcode, f.fault.faultstring)

> Thanks
> Donald W. Long
> Email: Donald.W.Long at thelongsfamily.com
> Skype: Donald.W.Long
>
> ------ Original Message ------
> From: "Donald W. Long" <donald.w.long at gmail.com>
> To: suds at lists.fedoraproject.org
> Sent: 5/26/2010 2:25:48 PM
> Subject: Dealing with exceptions from the web services
>> Message: 3
>> Date: Tue, 25 May 2010 10:43:09 -0800
>> From: "Joshua J. Kugler" <joshua at eeinternet.com>
>> Subject: Re: [Fedora-suds-list] Dealing with exceptions from the web
>> services
>> To: suds at lists.fedoraproject.org, "Donald W. Long"
>> <donald.w.long at gmail.com>
>> Message-ID: <201005251043.09590.joshua at eeinternet.com>
>> Content-Type: text/plain; charset="iso-8859-1"
>>
>> On Tuesday 25 May 2010, Donald W. Long elucidated thus:
>>> I found that if the service returns a string value and the service
>>> throws an exception i can look at the result and it will contain
>>> 'soap:Server', but if the service returns void then you can not tell
>>> if you have an error or not.
>>>
>>>
>>> But what I am really trying to figure out, is how do you see what
>>> exception the service has thrown.
>>>
>>> You may noticed that I am using the WindowsHttpAuthenticated, this is
>>> required for access to the server that is running the web services.
>>
>> If you are not seeing a suds.WebFault raised then the service is not
>> raising a SOAPFault, and thus is returning error information to you
>> other ways. If the service does not raise a SOAPFault on errors, then
>> you will have to wrap the call and raise an exception if an error
>> condition is returned.
>> I understand the above but we did a test with C#, below is some of the
>> code and we get a soap error.
>> public partial class _Default : System.Web.UI.page
>> {
>> protected void Page_load(object sender, EventArgs e)
>> {
>> SAWebServices ws = new SAWebService();
>> try
>> {
>> ws.GetBuildLocation(string.Empty);
>> }
>> catch (SoapException se)
>> {
>> Response.Write(se.Detail);
>> }
>> }
>> }
>> the above code will get a SoapException if an empty string is sent to
>> GetBuildLocation. The service is written in .NET ASP. From what I have
>> been told, Microsoft always converts the exception into a Soap
>> Exception. When we also use perl we get an exception for the client
>> code but not using python and suds. Should the SoapException be
>> something else?
>> We are at a loss on this one and not sure how to continue using suds
>> with Python. Given all other languages that we use, C# and perl we get
>> an exception from it. With Python and suds we only get a string that
>> says Soap:Server.
>> What type of exception should we throw for the web service, and what I
>> do not understand is given all these other languages and packages
>> work, what is the difference between suds and what they are doing.
>> Most of the developers in my area feel that suds is not handling
>> exceptions correctly, me, I am not sure, I am new at soap.
>> If you have any recommendations on what we should do then please let
>> us know. We would really like to move to Python and suds.
>> Have a nice day
>> Donald W. Long
>> Email: Donald.W.Long at thelongsfamily.com
>> Skype: Donald.W.Long
>
>
> _______________________________________________
> suds mailing list
> suds at lists.fedoraproject.org
> https://admin.fedoraproject.org/mailman/listinfo/suds

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5126 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.fedoraproject.org/pipermail/suds/attachments/20100527/ad143cef/attachment.bin 


More information about the suds mailing list