[Soap-Python] Array and max_occurs

Luca Dariz luca.dariz at unife.it
Mon Aug 16 11:29:37 CEST 2010


Hi,

i am a bit confised about array serialization in soaplib.

One usually defines an array with

@rpc(Array(String))
def echo(self, s)

that requires an envelope like

<SOAP-ENV:Envelope xmlns:ns0="root_dev" 
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:echo>
<ns0:s>
<ns0:string>s</ns0:string>
<ns0:string>a</ns0:string>
<ns0:string>r</ns0:string>
</ns0:s>
</ns0:echo>
</ns1:Body>
</SOAP-ENV:Envelope>


but one could also write

@rpc(String(min_occurs=1, max_occurs=10))
def echo(self, s)

that would need

<SOAP-ENV:Envelope xmlns:ns0="root_dev" 
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:echo>
<ns0:s>s</ns0:s>
<ns0:s>a</ns0:s>
<ns0:s>r</ns0:s>
</ns0:echo>
</ns1:Body>
</SOAP-ENV:Envelope>


but the latter will not work since only the last value found in the 
envelope is passed to the method; I attach a little patch that tries to 
fix it.

However in the two cases the envelope is different, and i think the 
envelope resulting from the second approach is simpler and maybe more 
compatible with different clients.

What do you think is the best way to serialize arrays?

Luca
-------------- next part --------------
A non-text attachment was scrubbed...
Name: max_occurs.patch
Type: text/x-patch
Size: 1516 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/soap/attachments/20100816/b876bef9/attachment.bin>


More information about the Soap mailing list