![]() |
Python SOAP client problem
Hi,
I'm having a lot of problem making a SAOP client in Python. I have tried various methods, but non of them seems to work for me. I have a .Net web service, available from an IIS server on another machine. I can access it trough browser, and everything works fine. The function I need to call is .RunTranslate. It takes one string argument inText, and 2 custom enumeration arguments, inLang and outLang (I suppose they are serialized/deserialized as string), a returns one string value as translation. Now, what I have tried: 1. SOAPy library import soap server = soap.get_proxy('http://192.168.1.72/sts/TranslatorService.asmx?wsdl','wsdl') translation = server.RunTranslate(inText="translate this", inLang="English", outLang="German") I get the following error: File "/usr/lib/python2.5/site-packages/soap.py", line 263, in __init__ sys.exit(1) NameError: global name 'sys' is not defined I tried to make the proxy with sdl, not wsdl, with: server = soap.get_proxy('http://192.168.1.72/sts/TranslatorService.asmx?SDL','sdl') But then I get this error File "/usr/lib/python2.5/site-packages/_xmlplus/dom/ext/reader/PyExpat.py", line 65, in fromStream success = self.parser.ParseFile(stream) xml.parsers.expat. ExpatError: mismatched tag: line 61, column 16 2. ZSI library from ZSI import ServiceProxy server = ServiceProxy('http://192.168.1.72/sts/TranslatorService.asmx?wsdl') translation = server.RunTranslate(inText="translate this", inLang="English", outLang="German") This produces the following error File "./main.py", line 25, in translate server = ServiceProxy('http://192.168.1.72/sts/TranslatorService.asmx?wsdl') TypeError: 'module' object is not callable 3. Sending HTTP POST request with httplib import httplib httpServ = httplib.HTTPConnection("http://192.168.1.72", 80) httpServ.connect() httpServ.request('POST', '/sts/TranslatorService.asmx?op=RunTranslate','inText=tr anslat+this&inLang=English&outLang=Croatian') response = httpServ.getresponse() if response.status == httplib.OK: print (response.read()) httpServ.close() The error: File "/usr/lib/python2.5/httplib.py", line 667, in connect socket.SOCK_STREAM): socket.gaierror: (-3, 'Temporary failure in name resolution') 4. Sending HTTP POST request with urllib, urllib2 I don't have a code for this, I deleted it. But it produced similar errors like httplib I'm working in Maemo5 scratchbox. I have noticed that scratchbox has Internet connection, because I can use apt-get, with no problems. But it doesn't render HTML, because I can't open anything in its browser. Maybe this is creating all the problems, or am I doing something completely wrong. Any help would be greatly appreciated. |
Re: Python SOAP client problem
Quote:
missing an import sys? |
Re: Python SOAP client problem
You could try suds instead. Seems pretty straight forward. Here's some documentation: https://fedorahosted.org/suds/wiki/Documentation
python-suds is the package. |
Re: Python SOAP client problem
Quote:
Code:
from ZSI.ServiceProxy import ServiceProxy Code:
httpServ = httplib.HTTPConnection("192.168.1.72", 80) |
Re: Python SOAP client problem
Quote:
Anyway it isn't very imported because it fails at this line Code:
nodes = domobj.getElementsByTagName('definitions') Quote:
File "build/bdist.linux-i686/egg/ZSI/wstools/WSDLTools.py", line 1116, in getAddressBinding ZSI.wstools.WSDLTools.WSDLError: No address binding found in port. Quote:
However if I omit the first / in the uri path, it returns Bad Request HTTP Error. |
Re: Python SOAP client problem
I got it working with httplib2
I just send a request, get a XML reply. Then I just have to parse it correctly |
All times are GMT. The time now is 10:51. |
vBulletin® Version 3.8.8