hecsa / pysimplesoap

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

Can't set attributes for request tag #89

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

This is without a wsdl. Using the code from the raw client wiki example:

params = pysimplesoap.simplexml.SimpleXMLElement("""<?xml version="1.0" 
encoding="UTF-8"?>
<AddIntegers a="b"><a>3</a><b>2</b></AddIntegers>""") # manually make request 
msg
response = client.call('AddIntegers',params)

AddIntegers has the attribute "a", but when calling the request, this attribute 
will be stripped out. This is because client.call generates skeleton xml based 
only on the method name and namespace stuff already setup, and when it adds the 
SimpleXMLElement structure it imports the children of the top-most (ie request) 
tag, but not any data from the tag itself.

What is the expected output? What do you see instead?

From a trace, this is the output I would desire:

<?xml version="1.0" encoding="UTF-8"?><soap:Envelope 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Header/>
<soap:Body>
    <AddIntegers a="b" xmlns="http://127.0.0.1:8000/webservices/sample/call/soap">
    <a>3</a><b>2</b></AddIntegers>
</soap:Body>
</soap:Envelope>

This is the actual output:

<?xml version="1.0" encoding="UTF-8"?><soap:Envelope 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Header/>
<soap:Body>
    <AddIntegers xmlns="http://127.0.0.1:8000/webservices/sample/call/soap">
    <a>3</a><b>2</b></AddIntegers>
</soap:Body>
</soap:Envelope>

What version of the product are you using? On what operating system?

Latest version, straight from repo a few days ago.

Please provide any additional information below.

Testing really quick, I think adding:

for k,v in parameters[0].attributes().items():
    getattr(request, method)[k] = v

to the end of the section in client.call merging the first SimpleXMLElement arg 
would fix the issue (starting as line 177 of client.py, same indent as for loop 
on 175).

Original issue reported on code.google.com by secreti...@gmail.com on 11 Jan 2013 at 10:00

GoogleCodeExporter commented 9 years ago
can you provide a patch or diff?
also, testcases would be useful

Original comment by reingart@gmail.com on 14 Jan 2013 at 6:43

GoogleCodeExporter commented 9 years ago

I've included a patch for client.py.

I'm not sure how best to produce a useful testcase for this since the issue 
happens during the client call request, making the erroneous (or correct) 
output only visible either in the trace output or from the server result.

I have, however, included a small script that, while not useful as a unit test, 
can be used to visually verify an xml object against it's traced output during 
a soap request. The 'a="b"' attribute/value on the "test" request tag will be 
visible in the first printout, but not the second (trace) output without the 
included patch. After the patch, both sets of output should be identical (minus 
the xmlsn attribute that is also added).

Original comment by secreti...@gmail.com on 18 Jan 2013 at 9:14

Attachments:

GoogleCodeExporter commented 9 years ago
Hi,

I stumbled uppon the same issue and worked arround it a different way (passing 
an "attributes" param to call()) but I find secretions approach much more 
logical.

Original comment by joce...@crapouillou.net on 30 Sep 2013 at 8:15

GoogleCodeExporter commented 9 years ago
Bump.

Any update ?

Original comment by joce...@crapouillou.net on 27 Nov 2013 at 2:04

GoogleCodeExporter commented 9 years ago
Sorry for the delays.

If you can, please make a pull request on github (that will be faster and 
easier to merge the patch):

https://github.com/pysimplesoap/pysimplesoap

Original comment by reingart@gmail.com on 20 Dec 2013 at 7:45

GoogleCodeExporter commented 9 years ago
Sorry for my own delay--didn't see this last issue update email. I've just made 
a github pull request for the patch I included previously.

Original comment by secreti...@gmail.com on 15 Jan 2014 at 10:06

GoogleCodeExporter commented 9 years ago
test added in a4b486f420635efe18f84445e590c638f28a759c

Original comment by oczk...@gmail.com on 15 Jan 2014 at 10:43