[Fedora-suds-list] Processing Complex Returns

Jeff Ortel jortel at redhat.com
Tue Jun 16 20:16:52 UTC 2009


Hey Tim,

Suds provides an objectification of the XML defined for the service (method) parameters 
and returned objects.  So, in this case it looks like the method returns an 
ApplicationTrace object (based on the information you provided).  Assuming you've assigned 
this to a variable such as:

 >
 > trace = client.service.getApplicationTrace(...)
 >

Then, trace looks like this:

 >
 > print trace
 >

(ApplicationTrace){      <-------- The () indicates that class.
    Application = False
    CCode = False
    CCodeLevel = "0"
    Concurrency = False
    Gateway = False
    GatewayPerformance = False
    Performance = False
    PLSQLCode = False
    Security = False
    TraceOverrideList = ""
  }

So, the following should work:

 >
 > self.assertEqual(trace.Application, True)
 >

-or-

 >
 > If trace.Application:
 >  print "The application is true"
 >

.. And so on.

Hopes this helps,

Jeff



Tim Sawyer wrote:
> Hi Folks,
> 
> I have a web service that returns the following:
> 
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
> <SOAP:Body>
> <tns:GetApplicationTraceResponseParameter
> xmlns:tns="http://ws.company.com/wsdl"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><tns:ApplicationTrace>
> <tns:Application>false</tns:Application>
> <tns:CCode>false</tns:CCode>
> <tns:CCodeLevel>0</tns:CCodeLevel>
> <tns:Concurrency>false</tns:Concurrency>
> <tns:Gateway>false</tns:Gateway>
> <tns:GatewayPerformance>false</tns:GatewayPerformance>
> <tns:Performance>false</tns:Performance>
> <tns:PLSQLCode>false</tns:PLSQLCode>
> <tns:Security>false</tns:Security>
> <tns:TraceOverrideList/></tns:ApplicationTrace>
> </tns:GetApplicationTraceResponseParameter>
> </SOAP:Body>
> </SOAP:Envelope>
> 
> I'm trying to write a test, using suds, of this web service.  I'm calling
> the web service, and then doing this to the results, which isn't working:
> 
> self.assertEqual(lResponseParameter.ApplicationTrace.Application, False)
> self.assertEqual(lResponseParameter.ApplicationTrace.CCode, False)
> self.assertEqual(lResponseParameter.ApplicationTrace.CCodeLevel, '0')
> self.assertEqual(lResponseParameter.ApplicationTrace.Concurrency, False)
> self.assertEqual(lResponseParameter.ApplicationTrace.Gateway, False)
> self.assertEqual(lResponseParameter.ApplicationTrace.GatewayPerformance,
> False)
> self.assertEqual(lResponseParameter.ApplicationTrace.PLSQLCode, False)
> self.assertEqual(lResponseParameter.ApplicationTrace.Security, False)
> 
> The error I get is:
> 
> AttributeError: 'function' object has no attribute 'Application'
> 
> I think it appears to think that ApplicationTrace is an __init__ function?
> 
> logging.info(lResponseParameter.ApplicationTrace)
> 
> gives:
> 
> INFO:root:<bound method ApplicationTrace.__init__ of (ApplicationTrace){
>    Application = False
>    CCode = False
>    CCodeLevel = "0"
>    Concurrency = False
>    Gateway = False
>    GatewayPerformance = False
>    Performance = False
>    PLSQLCode = False
>    Security = False
>    TraceOverrideList = ""
>  }>
> 
> so the data does appear to be there.
> 
> Any clues as to what I'm not understanding anyone?
> 
> Cheers,
> 
> Tim.
> 
> _______________________________________________
> fedora-suds-list mailing list
> fedora-suds-list at redhat.com
> https://www.redhat.com/mailman/listinfo/fedora-suds-list




More information about the fedora-suds-list mailing list