Active Topics

 


Reply
Thread Tools
Posts: 58 | Thanked: 10 times | Joined on Dec 2009
#1
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.
 
mece's Avatar
Posts: 1,111 | Thanked: 1,985 times | Joined on Aug 2009 @ Åbo, Finland
#2
Originally Posted by zolakt View Post
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
[...]
perhaps some bug in the soap library there?
missing an import sys?
__________________
Class .. : Meddler, Thread watcher, Developer, Helper
Humor .. : [********--] Alignment: Pacifist
Patience : [*****-----] Weapon(s): N900, N950, Metal music
Agro ... : [----------] Relic(s) : N95, NGage, Tamyia Wild One

Try Tweed Suit for your hardcore twittering needs
http://twitter.com/mece66
I like my coffee black, like my metal.
 
mece's Avatar
Posts: 1,111 | Thanked: 1,985 times | Joined on Aug 2009 @ Åbo, Finland
#3
You could try suds instead. Seems pretty straight forward. Here's some documentation: https://fedorahosted.org/suds/wiki/Documentation

python-suds is the package.
__________________
Class .. : Meddler, Thread watcher, Developer, Helper
Humor .. : [********--] Alignment: Pacifist
Patience : [*****-----] Weapon(s): N900, N950, Metal music
Agro ... : [----------] Relic(s) : N95, NGage, Tamyia Wild One

Try Tweed Suit for your hardcore twittering needs
http://twitter.com/mece66
I like my coffee black, like my metal.
 
Posts: 49 | Thanked: 41 times | Joined on Apr 2010
#4
Originally Posted by zolakt View Post
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
Not sure about the rest, but this should be imported as:
Code:
from ZSI.ServiceProxy import ServiceProxy
Ah - and httplib should be without "http://...":

Code:
httpServ = httplib.HTTPConnection("192.168.1.72", 80)

Last edited by viraptor; 2010-04-09 at 11:33.
 
Posts: 58 | Thanked: 10 times | Joined on Dec 2009
#5
Originally Posted by mece View Post
perhaps some bug in the soap library there?
missing an import sys?
sys is imported into script. But its not in the library.
Anyway it isn't very imported because it fails at this line
Code:
nodes = domobj.getElementsByTagName('definitions')
		if len(nodes) == 0:
			print "Couldn't find definitions tag!"
			sys.exit(1)

Originally Posted by viraptor View Post
Not sure about the rest, but this should be imported as:
Code:
from ZSI.ServiceProxy import ServiceProxy
Changed it and it hives a different error.
File "build/bdist.linux-i686/egg/ZSI/wstools/WSDLTools.py", line 1116, in getAddressBinding
ZSI.wstools.WSDLTools.WSDLError: No address binding found in port.

Originally Posted by viraptor View Post
Ah - and httplib should be without "http://...":
Code:
httpServ = httplib.HTTPConnection("192.168.1.72", 80)
When I do this, it doesn't give an error. But it returns nothing.
However if I omit the first / in the uri path, it returns Bad Request HTTP Error.
 
Posts: 58 | Thanked: 10 times | Joined on Dec 2009
#6
I got it working with httplib2
I just send a request, get a XML reply.

Then I just have to parse it correctly
 
Reply


 
Forum Jump


All times are GMT. The time now is 12:01.