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/%22%3E SOAP:Body tns:GetApplicationTraceResponseParameter xmlns:tns="http://ws.company.com/wsdl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"tns:ApplicationTrace tns:Applicationfalse</tns:Application> tns:CCodefalse</tns:CCode> tns:CCodeLevel0</tns:CCodeLevel> tns:Concurrencyfalse</tns:Concurrency> tns:Gatewayfalse</tns:Gateway> tns:GatewayPerformancefalse</tns:GatewayPerformance> tns:Performancefalse</tns:Performance> tns:PLSQLCodefalse</tns:PLSQLCode> tns:Securityfalse</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.
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/%22%3E SOAP:Body tns:GetApplicationTraceResponseParameter xmlns:tns="http://ws.company.com/wsdl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"tns:ApplicationTrace tns:Applicationfalse</tns:Application> tns:CCodefalse</tns:CCode> tns:CCodeLevel0</tns:CCodeLevel> tns:Concurrencyfalse</tns:Concurrency> tns:Gatewayfalse</tns:Gateway> tns:GatewayPerformancefalse</tns:GatewayPerformance> tns:Performancefalse</tns:Performance> tns:PLSQLCodefalse</tns:PLSQLCode> tns:Securityfalse</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@redhat.com https://www.redhat.com/mailman/listinfo/fedora-suds-list