[Fedora-suds-list] Processing Complex Returns

Tim Sawyer webmaster at rtb.org.uk
Thu Jun 18 13:02:50 UTC 2009


Thanks Jeff.

Oddly, this works on one of my tests:

lResponseParameter = lWebService.execute()
self.assertEqual(lResponseParameter.Person.ID, '196868')
self.assertEqual(lResponseParameter.Person.Firstname, 'Harry')
self.assertEqual(lResponseParameter.Person.Surname, 'Smith')

but not another

lResponseParameter = lWebService.execute()
self.assertEqual(lResponseParameter.ApplicationTrace.Application, False)
self.assertEqual(lResponseParameter.ApplicationTrace.CCode, False)

Not really sure why, I've kind of ignored this for now.  I'll see how it
goes as I develop more tests, see if I can pin down exactly when it
happens.

I'm using execute() to call suds's server.TxnName method, passing in the
correct parameters.  I'm actually trying to write a wrapper so that I can
run these tests both with suds and with iron python as a .net client. 
It's working for basic services, and I'm slowly trying to test some more
complex ones.

I'm now struggling with array type calls.  With my iron python tests, I do
the following in my test to create a list of AgreementStatus objects to
pass to the web service:

lWebService = self.loadWsdl('pdi-web-services.CheckDecision')
lWebService.UserName = 'user'
lWebService.Password = 'password'
lWebService.SecurityToken = None
lAgreementStatus = lWebService.create('AgreementStatus')
lAgreementStatus.AgreementNumber = 'CPP245231'
lWebService.AgreementStatusList = (lAgreementStatus,)
lResponseParameter = lWebService.execute()

With suds this produces XML that looks like this:

<ns0:CheckDecisionCallParameter>
  <ns0:AgreementStatusList>
    <ns0:AgreementNumber>CPP245231</ns0:AgreementNumber>
    <ns0:Decision xsi:nil="true"/>
    <ns0:FailureDateTime xsi:nil="true"/>
    <ns0:FailureReason xsi:nil="true"/>
  </ns0:AgreementStatusList>
  <ns0:Password>user</ns0:Password>
  <ns0:SecurityToken xsi:nil="true"/>
  <ns0:UserName>password</ns0:UserName>
</ns0:CheckDecisionCallParameter>

Which appears to be missing the container XML for each item in the
AgreementStatusList.  I'd expect to see:

<ns0:AgreementStatusList>
  <ns0:AgreementStatus>
    <ns0:AgreementNumber>CPP245231</ns0:AgreementNumber>

as a structure, which is what OxygenXML editor produces when I have it
look at the WSDL and generate XML for the web service call.

How can I get this? (hopefully without changing my test code so that it
breaks the iron python tests!)

Thanks,

Tim.

----------  Forwarded Message  ----------

Subject: Re: [Fedora-suds-list] Processing Complex Returns
Date: Tuesday 16 Jun 2009
From: Jeff Ortel <jortel at redhat.com>
To: Tim Sawyer <list.suds at calidris.co.uk>

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:Application
> Trace> <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.GatewayPerformanc
> e,
> 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