luizhandrade / pysimplesoap

Automatically exported from code.google.com/p/pysimplesoap
0 stars 0 forks source link

The soap dispatcher does not deal with arrays of dictionaries as returned by some soap clients like SUDS #37

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If you use a soap client such as SUDS the example method 'adder' in the 
server.py main does not work.

Suds generates slightly different xml for the call to :- 

response = 
client.Adder(p={'a':1,'b':2},dt='2010-07-24',c=[{'d':'1.20'},{'d':'2.01'}])

it generates:- 

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://www.affinitext.com/ACSSoap/" 
                   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:Adder>
               <ns0:p>
                   <ns0:a>1</ns0:a>
                   <ns0:b>2</ns0:b>
               </ns0:p>
               <ns0:dt>2010-07-24</ns0:dt>
               <ns0:c>
                   <ns0:d>1.20</ns0:d>
                </ns0:c>
                <ns0:c>
                     <ns0:d>2.01</ns0:d>
               </ns0:c>
          </ns0:Adder>
    </ns1:Body>
</SOAP-ENV:Envelope>

the 2 <ns0:c> elements get collapsed to one.  This is caused inside 
simplexml.py in the unmarshall method.   Basically if a list is encountered it 
is initialized to an empty list for each <ns0:c> rather than appending to the 
existing list.

the fix is simple in that the code 

value = []

just needs to be changed to:-

value = d.setdefault(name, [])

I have attached a diff file to help zero in on the line.

Original issue reported on code.google.com by pfra...@gmail.com on 18 Aug 2011 at 6:25

Attachments:

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 734ace0eac90.

Original comment by reingart@gmail.com on 23 Nov 2011 at 7:31

GoogleCodeExporter commented 9 years ago
Thanks, this was commited in 734ace0eac90, could you test my experimental 
branch?

http://code.google.com/p/pysimplesoap/source/list?name=reingart

hg clone https://reingart@code.google.com/p/pysimplesoap/ 
hg update reingart

Original comment by reingart@gmail.com on 23 Nov 2011 at 7:33