kartagis / pysimplesoap

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

Namespace handling at top level parameters in WSDL call #143

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Upgrade from PySimpleSOAP v1.10 to newest
2. Connect to VMware vCenter Orechestrator API (Axis SOAP WSDL)
3. Try to execute any workflow

What is the expected output? What do you see instead?
In v1.10 the workflow is executed and the workflow token is returned
in v.1.13 (latest) Python output an error:
AttributeError: 'dict' object has no attribute 'namespaces'
With the stack trace pointing to line 370 in wsdl_call_get_params in client.py.

What version of the product are you using? On what operating system?
v1.13 (previously v1.10) on Debian Linux 7.4 with Python 2.6.6.

Please provide any additional information below.
I traced the problem to the rev ea327a924ac7, in client.py at line 366, the new 
code block assume that "root.namespaces[k]" exists, where it does not 
necessarily (in fact using pdb, "root.namespaces" itself does not exist at this 
time).
I think you should check first if "root.namespaces" exist and if 
"root.namespaces[k]" exist before using it here.

Regards,
Sylvain.

Original issue reported on code.google.com by sylv...@huguet.me on 24 May 2014 at 10:11

GoogleCodeExporter commented 8 years ago
Thanks for reporting!
Could you attach the WSDL and a small example so I can reproduce and fix this 
issue?

Original comment by reingart@gmail.com on 24 May 2014 at 1:53

GoogleCodeExporter commented 8 years ago
I created a pastbin with the code exemple and the Traceback below the code: 
http://pastebin.com/Fi3reU9Z

Also, the WSDL is from a commercial third party product, I tried to download it 
as a file, it is attached.

Sylvain.

Original comment by sylv...@huguet.me on 24 May 2014 at 3:00

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks!

With the wsdl and the example I could reproduce it, there were two errors:
 * workflowInputs was not properly detected as an array
 * top level parameter's namespace is not handled correctly if it is not a compound element (list or scalar will fail)

I've made a commit (revision f8d1152c34de), could you test it? specially the 
array handling (for example, multiple workflowInputs in your wsdl)

Also, I've added a test (revision 0a71e70ad0b7) but I'm not sure how xml should 
be in the request / response, if you can attach a working sample that would be 
very helpfull too

Original comment by reingart@gmail.com on 25 May 2014 at 1:10

GoogleCodeExporter commented 8 years ago
At first sight, it goes further/is not blocking with the AttributeError.

But so much as change between the 1.14 and the 1.10 that I will need to modify 
a lot of my code to be able to validate that everything works.

A simple exemple: the function "getWorkflowsWithName" used to return a list of 
"getWorkflowsWithNameReturn" arrays. Now it returns an array with a single key 
"getWorkflowsWithNameReturn" with the value being a list of all the returns.

Before the upgrade, I used to access the return with 
response[0]['getWorkflowsWithNameReturn'] now it's 
response['getWorkflowsWithNameReturn'][0].

All the logic is reversed, so I need to rework my wrapper class before I can 
give a definitive answer.

I'll look into it on Monday.

Thanks,
Sylvain.

Original comment by sylv...@huguet.me on 25 May 2014 at 7:24

GoogleCodeExporter commented 8 years ago
I've reverted the array structure logic so you could use 
response[0]['getWorkflowsWithNameReturn'] and there should be no need change 
your code in most cases (see revision 0f9a9044c1c7).
That behaviour could be controlled with the soap_server parameter (currenly, 
only "jetty" uses the new logic, except some complex structures)

Thanks for testing!
You feedback is very helpful

Original comment by reingart@gmail.com on 25 May 2014 at 4:53

GoogleCodeExporter commented 8 years ago
Hello,

I had some time to revisit the topic this morning.
The logic is indeed revert, but when I try to call anothrr function 
(getWorkflowTokenStatus) with a code like this:
vcoWS.getWorkflowTokenStatus(workflowIds="01234abc", username="myuser", 
password="mypass")
I get the same error as the last time (AttributeError: 'dict' object has no 
attribute 'namespaces') at line 370 in client.py.

Sylvain

Original comment by sylv...@huguet.me on 27 May 2014 at 8:25

GoogleCodeExporter commented 8 years ago
Thanks for testing

I've fixed scalar array support (new style "jetty") in revision b266017b6e3f

It will work for this cases like in workflowTokenIds that is a list of strings:

vcoWS.getWorkflowTokenStatus(workflowTokenIds=["01234abc"], username="myuser", 
password="mypass")

(your example says workflowIds, but the correct one is workflowTokenIds)

BTW, the AttributeError should not happen, it is a sympthom of the incorrect 
structure (list, scalar or None) parsed as a top level parameter (that's why I 
didn't change it and instead I'm looking to fix the causes)

Please test it and let me know if this resolved your issue

Original comment by reingart@gmail.com on 27 May 2014 at 3:01

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
It is working fine using this last release!
Thanks for the fixes, I can get back to work now, no excuses :)

Sylvain.

Original comment by sylv...@huguet.me on 28 May 2014 at 9:27