KenyaDonDraper / pysimplesoap

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

Choice element not supported #23

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. using https://apitest.authorize.net/soap/v1/Service.asmx?WSDL for my WSDL 
create a client with version 1.02c
2. attempt to call GetCustomerProfile with a profile ID that includes a 
paymentProfile that has a 'creditCard' payment associated with it

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

I expect the response to be properly parsed and include all information.  
Instead SimpleXML throws an error that 'creditCard' is an invalid type.  Upon 
inspection i see that the 'payment' field of 'CustomerPaymentProfile' has 
expected types of 'None'.  I dug in and figured out that this was because the 
'payment' field has a 'choice' element.

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

version 1.02c, in web2py, running from source with the GAE development 
environment.

Please provide any additional information below.

The solution that works for me is the following change (diff based off of 
web2py release Version 1.92.1 (2011-02-16 15:04:40))

--- a/web2py/gluon/contrib/pysimplesoap/client.py   Fri Mar 04 09:12:39 2011 -0800
+++ b/web2py/gluon/contrib/pysimplesoap/client.py   Sun Mar 06 15:25:50 2011 -0800
@@ -356,6 +356,11 @@
                     if debug: print element_name,"has not children!",tag
                     continue #TODO: abstract?
                 d = OrderedDict()                    
+
+                if len(children)==1 and children[0].get_local_name()=='choice' 
\
+                       and children[0].children():
+                    children=children[0].children()
+
                 for e in children:
                     t = e['type']
                     if not t:

Original issue reported on code.google.com by cfho...@cfhowes.com on 6 Mar 2011 at 11:27

GoogleCodeExporter commented 9 years ago
I've had a bit of trouble related to choice elements as well, but I solved it a 
different way.

I needed to be able to add the elements in choice to the siblings of the choice 
element.  The patch above was just returning the children within the choice.

My fix only gets the first element within choice, which worked for my useage, 
but is still not ideal.

for e in children:
# If a choice element, return the first choice as the element to work with.
  if e.get_local_name()=='choice'\
      and e.children():
      e = e.children()[0]
# Continue with loop

Original comment by j...@mclemoreauction.com on 25 Jun 2011 at 4:49

GoogleCodeExporter commented 9 years ago
Could you provide a xml messages to test this patches?

Original comment by reingart@gmail.com on 6 Jan 2012 at 5:35

GoogleCodeExporter commented 9 years ago
Unfortunately, I've ceased using this library, and no longer have the source 
code to my modifications.

Original comment by j...@mclemoreauction.com on 9 Jan 2012 at 10:49

GoogleCodeExporter commented 9 years ago
i am pretty sure i'm still using it.  i'll try and get some sample XML.

Original comment by cfho...@cfhowes.com on 9 Jan 2012 at 10:53