(Migrated) Best way to receive and return SOAP complex Types

(This message has been automatically imported from the retired mailing list)

Hello,

I have to implement services that receives and answer specific complexType
pre-defined by the software acting as the SOAP client.

As I understand from https://zato.io/docs/progguide/request-response.html
self.request.payload should return lxml.objectify.ObjectifiedElement but
for some reason I don’t see it and decided to work with the raw request,
that was fine and now all requests are being correctly handled.

My problem is returning a response with the following complex type:
<xsd:complexType name=“StatusResult”>
xsd:sequence
<xsd:element name=“result” type=“xsd:int”/>
<xsd:element name=“reasonCode” nillable=“true” type=“xsd:int”/>
<xsd:element name=“errMsg” nillable=“true” type=“xsd1:Error”/>
<xsd:element minOccurs=“0” maxOccurs=“unbounded” name="Atts"
nillable="true"
type=“xsd1:Att”/>
<xsd:element name=“requestId” nillable=“true” type=“xsd:string”/>
</xsd:sequence>
</xsd:complexType>

I have used wsdl2py and then added the generated classes into
zato_extra_paths, so now I can easily create the complex object in python.

My questions are:

  • How should I return this objects in the response?
  • For the request, what I am doing is working well but I guess there is a
    much simpler way. Is there?

I am attaching the wsdl supplied by the software vendor and the py
generated by wsdl2py.

Thanks in advance for any help/thoughts on this subject.

Best Regards,
Guilherme

Hello Dariusz!

I will do the way you explained.

About the new library, I will keep an eye on it! I use mitmproxy and I will
capture all requests and responses as soon I finish it.

[]s!
Guilherme

On Tue, Dec 22, 2015 at 6:25 PM, Dariusz Suchojad dsuch@zato.io wrote:

On 22/12/15 21:18, Guilherme Monteiro wrote:

Hi Guilherme,

My questions are:

  • How should I return this objects in the response?

since you are working with custom objects producing responses the
easiest way would be to simply serialize your objects to string and
attached them to self.response.payload, i.e. something along the lines of:

self.response.payload = myobject.to_string()

That is, if self.response.payload is a string, it is never overwritten
by Zato, the assumption here is that if a user uses string then they
know what they do and it is used 1:1.

  • For the request, what I am doing is working well but I guess there is
    a much simpler way. Is there?

Actually, there will be a new simpler way in a few months. I’m working
on a new JSON/XML/CSV library for Python and I’m quite certain it will
be the most convenient way to handle these types of documents.

It will be released as a separate project on PyPI and the next major
Zato version will make use of it.

You can help by sending across a few samples of XML you would like to
generate - I’ll be sure to include them in test cases for the library.

On 22/12/15 21:18, Guilherme Monteiro wrote:

Hi Guilherme,

My questions are:

  • How should I return this objects in the response?

since you are working with custom objects producing responses the
easiest way would be to simply serialize your objects to string and
attached them to self.response.payload, i.e. something along the lines of:

self.response.payload = myobject.to_string()

That is, if self.response.payload is a string, it is never overwritten
by Zato, the assumption here is that if a user uses string then they
know what they do and it is used 1:1.

  • For the request, what I am doing is working well but I guess there is
    a much simpler way. Is there?

Actually, there will be a new simpler way in a few months. I’m working
on a new JSON/XML/CSV library for Python and I’m quite certain it will
be the most convenient way to handle these types of documents.

It will be released as a separate project on PyPI and the next major
Zato version will make use of it.

You can help by sending across a few samples of XML you would like to
generate - I’ll be sure to include them in test cases for the library.