kartagis / pysimplesoap

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

SoapClient did not build all arguments for Marketo (patch included) #104

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
#----------------------------------------------------
What steps will reproduce the problem?
import pysimplesoap

# add Marketo soap namespace to pysimplesoap
soap_ns = 'SOAP-ENV'
if not pysimplesoap.client.soap_namespaces.get(soap_ns):
    pysimplesoap.client.soap_namespaces[soap_ns] = 'http://schemas.xmlsoap.org/soap/envelope/'

# init SoapClient
wsdl_url='http://app.marketo.com/soap/mktows/2_1?WSDL'

# location/soap_endpoint : This is specific for a marketo client.
# Normally the client ignores this field when using wsdl, Which will just 
return a server error, but still show the output. 
# The included patch also checks for self.location before it is overriden in 
get_operation()
# For testing, do not specify location so it will use the wsdl
soap_endpoint=''

ns = 'ns1'
namespace='http://www.marketo.com/mktows/'
client = pysimplesoap.client.SoapClient(wsdl=wsdl_url, location=soap_endpoint, 
soap_ns=soap_ns, ns=ns, namespace=namespace, trace=True)

method = 'getLead'
args = {'paramsGetLead':{'leadKey':{'keyType':'IDNUM', 'keyValue':'1'}}}

# *args method:
client.wsdl_call(method, args)

# **kwargs method:
client.wsdl_call(method, paramsGetLead=args['paramsGetLead'])

#----------------------------------------------------
What is the expected output? What do you see instead?
Expected (using either *args or **kwargs method):
<ns1:paramsGetLead>
    <leadKey>
        <keyType>IDNUM</keyType>
        <keyValue>1</keyValue>
    </leadKey>
</ns1:paramsGetLead>

Received (using *args method):
<ns1:paramsGetLead>
    <leadKey/>
</ns1:paramsGetLead>

Received (using **kwargs method):
# Nothing at all

#----------------------------------------------------
What version of the product are you using? On what operating system?
changeset:   165:d3d167931bc0
SoapClient 1.08b
Python 2.6
CentOS 5.4

#----------------------------------------------------
Please provide any additional information below.
- This was a simple example of possible input. It can get rather deep. However, 
the output is always the same with the original version tested with.
- I do not have any other wsdl / servers to test these changes against other 
than Marketo at this time.
- I have separated wsdl_call() out into two additional methods: 
wsdl_call_get_params() and wsdl_sort_dict()

Original issue reported on code.google.com by b...@webreply.com on 6 Jun 2013 at 2:15

Attachments:

GoogleCodeExporter commented 8 years ago
Merged into new branch and added test suite but looks like it's breaking other 
tests:

ERROR: Test Argentina AFIP Electronic Invoice WSFEXv1 GetCMP method
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/root/git/forks/pysimplesoap/tests/afip_tests.py", line 128, in test_wsfexv1_getcmp
    'Cbte_nro': "38",
  File "/root/git/forks/pysimplesoap/pysimplesoap/client.py", line 147, in <lambda>
    return lambda *args, **kwargs: self.wsdl_call(attr,*args,**kwargs)
  File "/root/git/forks/pysimplesoap/pysimplesoap/client.py", line 300, in wsdl_call
    method, params = self.wsdl_call_get_params(method, input, *args, **kwargs)
  File "/root/git/forks/pysimplesoap/pysimplesoap/client.py", line 328, in wsdl_call_get_params
    params = self.wsdl_sort_dict(input, kwargs).values()[0].items()
IndexError: list index out of range

I'll look at this in weekend but feel free to fix earlier ;-).
https://github.com/pysimplesoap/pysimplesoap/tree/bill

Original comment by oczk...@gmail.com on 6 Jun 2013 at 10:02

GoogleCodeExporter commented 8 years ago

Original comment by oczk...@gmail.com on 6 Jun 2013 at 10:05

GoogleCodeExporter commented 8 years ago
Thank you for accepting this so quick!
I've forked, debugged, and submitted a pull request on github for you.
Also added a structure validation method I was using when I found I was sending 
bad data that didn't match the wsdl.

Original comment by b...@webreply.com on 7 Jun 2013 at 3:36

GoogleCodeExporter commented 8 years ago
I've just merged this into dev branch (it would be merged into master/default 
when we finish sync script etc.), hope it's ok for you?

I'll leave this open until we get sync with github 
(https://github.com/pysimplesoap/pysimplesoap)

Original comment by oczk...@gmail.com on 8 Jun 2013 at 10:52

GoogleCodeExporter commented 8 years ago
Sounds great, Thank you!!!

Original comment by b...@webreply.com on 11 Jun 2013 at 1:41

GoogleCodeExporter commented 8 years ago
test about this are passing and we have the issue 111 about github mirror sync
thanks!

Original comment by reingart@gmail.com on 13 Sep 2013 at 3:40