[Soap-Python] trouble calling service (pysimplesoap)

Scobie Smith devcom at infinitiv.com
Tue Feb 11 01:49:00 CET 2014


Hi,

 

I'm relatively new to Python and certainly new to consuming web services via
Python.

I have a WCF (.NET) service (SOAP), which I am trying to call from Python.

I've tried osa, but that failed to parse the wsdl successfully. (I'm not
sure what the easiest/best library is....)

Now I'm using pysimplesoap, but I get the following error.

My service has a no-op method, for testing purposes: void NoOp(). In other
words, the service method does absolutely nothing and returns nothing. This
is just to test that pysimplesoap can successfully call the method. Here is
my python code:

 

from pysimplesoap.client import SoapClient

 

wsdl_url =
'http://localhost:8733/Design_Time_Addresses/LexemeRepositoryServiceLibrary/
LexemeRepositoryService/?wsdl'

 

client = SoapClient(wsdl=wsdl_url)

 

s = client.NoOp()

 

print(s)

 

The code fails on the call to NoOp() with the following output:

 

Traceback (most recent call last):

  File "lexsoap.py", line 8, in <module>

    s = client.NoOp()

  File
"C:\Python33\lib\site-packages\pysimplesoap-1.10-py3.3.egg\pysimplesoap\clie
nt.py", line 141, in <lambda>

  File
"C:\Python33\lib\site-packages\pysimplesoap-1.10-py3.3.egg\pysimplesoap\clie
nt.py", line 285, in wsdl_call

  File
"C:\Python33\lib\site-packages\pysimplesoap-1.10-py3.3.egg\pysimplesoap\clie
nt.py", line 207, in call

  File
"C:\Python33\lib\site-packages\pysimplesoap-1.10-py3.3.egg\pysimplesoap\clie
nt.py", line 236, in send

  File
"C:\Python33\lib\site-packages\pysimplesoap-1.10-py3.3.egg\pysimplesoap\tran
sport.py", line 125, in request

UnboundLocalError: local variable 'f' referenced before assignment

 

Since my code does nothing, this looks like a problem within pysimplesoap.

When I examine transport.py, the request function is this:

 

    def request(self, url, method="GET", body=None, headers={}):

        req = urllib2.Request(url, body, headers)

        try:

            f = self.request_opener(req, timeout=self._timeout)

        except urllib2.HTTPError as f:

            if f.code != 500:

                raise

        return f.info(), f.read()

 

I'm not inclined to debug pysimplesoap, so if anyone has any thoughts, I
think you in advance....

 

Thanks.

S. Smith

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/soap/attachments/20140211/c5d37080/attachment.html>


More information about the Soap mailing list