On 11 February 2014 02:31, Scobie Smith <[email protected]> wrote:
> 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\client.py", > line 141, in <lambda> > > File > "C:\Python33\lib\site-packages\pysimplesoap-1.10-py3.3.egg\pysimplesoap\client.py", > line 285, in wsdl_call > > File > "C:\Python33\lib\site-packages\pysimplesoap-1.10-py3.3.egg\pysimplesoap\client.py", > line 207, in call > > File > "C:\Python33\lib\site-packages\pysimplesoap-1.10-py3.3.egg\pysimplesoap\client.py", > line 236, in send > > File > "C:\Python33\lib\site-packages\pysimplesoap-1.10-py3.3.egg\pysimplesoap\transport.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() > Looks like a bug. You might get a more useful error by changing it to: def request(self, url, method="GET", body=None, headers={}): req = urllib2.Request(url, body, headers) f = None try: f = self.request_opener(req, timeout=self._timeout) except urllib2.HTTPError as f: if f is None or f.code != 500: raise return f.info(), f.read() -- Michael Wood <[email protected]>
_______________________________________________ Soap mailing list [email protected] https://mail.python.org/mailman/listinfo/soap
