falc410 / pysimplesoap

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

error calling client method without parameters #133

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Using Python 2.7.3 and IPython:

In [1]: import pysimplesoap 

In [2]: pysimplesoap.__version__
Out[2]: '1.10'

In [3]: client = 
pysimplesoap.client.SoapClient(wsdl="http://cpdb.molgen.mpg.de/download/CPDB.wsd
l")

In [4]: client.location
Out[4]: u'http://cpdb.molgen.mpg.de/ws2/'

In [5]: client.namespace
Out[5]: u'cpdbns'

In [6]: client.getCpdbVersion()
---------------------------------------------------------------------------
SoapFault                                 Traceback (most recent call last)
<ipython-input-10-b13a889a38cd> in <module>()
----> 1 client.getCpdbVersion()

/home/beber/.virtualenvs/cpdb_wsdl/lib/python2.7/site-packages/pysimplesoap/clie
nt.pyc in <lambda>(*args, **kwargs)
    139             return lambda self=self, *args, **kwargs: self.call(attr, *args, **kwargs)
    140         else:  # using WSDL:
--> 141             return lambda *args, **kwargs: self.wsdl_call(attr, *args, 
**kwargs)
    142 
    143     def call(self, method, *args, **kwargs):

/home/beber/.virtualenvs/cpdb_wsdl/lib/python2.7/site-packages/pysimplesoap/clie
nt.pyc in wsdl_call(self, method, *args, **kwargs)
    283 
    284         # call remote procedure
--> 285         response = self.call(method, *params)
    286         # parse results:
    287         resp = response('Body', ns=soap_uri).children().unmarshall(output)

/home/beber/.virtualenvs/cpdb_wsdl/lib/python2.7/site-packages/pysimplesoap/clie
nt.pyc in call(self, method, *args, **kwargs)
    209                                     jetty=self.__soap_server in ('jetty',))
    210         if self.exceptions and response("Fault", ns=list(soap_namespaces.values()), error=False):
--> 211             raise SoapFault(response.faultcode, response.faultstring)
    212         return response
    213 

SoapFault: SOAP-ENV:Client: Unparseable message

Since the message is unparseable, I constructed it myself and tried, which 
works:

In [7]: params = pysimplesoap.simplexml.SimpleXMLElement("""<?xml version="1.0" 
encoding="UTF-8"?>                             
<getCpdbVersion></getCpdbVersion>""")

In [8]: response = client.call("getCpdbVersion", params)

In [9]: response
Out[9]: <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Header/><SOAP-EN
V:Body 
xmlns:ns1="cpdbns"><ns1:getCpdbVersionResponse><ns1:cpdbVersion>cpdb28</ns1:cpdb
Version></ns1:getCpdbVersionResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

So the proper result is in there. so what's going wrong before?

In [10]: operation = client.get_operation("getCpdbVersion")

In [11]: client.wsdl_call_get_params("getCpdbVersion", operation["input"])
Out[11]: ('getCpdbVersion', {})

In [12]: client.call("getCpdbVersion", *{})
---------------------------------------------------------------------------
SoapFault                                 Traceback (most recent call last)
<ipython-input-18-bcc6dd08598f> in <module>()
----> 1 client.call("getCpdbVersion", *{})

/home/beber/.virtualenvs/cpdb_wsdl/lib/python2.7/site-packages/pysimplesoap/clie
nt.pyc in call(self, method, *args, **kwargs)
    209                                     jetty=self.__soap_server in ('jetty',))
    210         if self.exceptions and response("Fault", ns=list(soap_namespaces.values()), error=False):
--> 211             raise SoapFault(response.faultcode, response.faultstring)
    212         return response
    213 

SoapFault: SOAP-ENV:Client: Unparseable message

If this can somehow be easily fixed, I'm willing to provide a patch but I'm not 
sure where to start right now.

Original issue reported on code.google.com by moritz.b...@gmail.com on 6 Feb 2014 at 3:12