.NET Web Services

Jeremiah McElroy jeremiah at facility9.com
Mon Jul 21 02:03:06 CEST 2003


I am attempting to connect from my local machine to a .NET web service I
found on Xmethods.net which provides dictionary lookups.  I am running
windows XP with Python 2.2.3 and win32all-152.  I'm using ZSI 1.2.

When I attempt to contact the web serivce, I see the following stack trace:

Traceback (most recent call last):
  File
"C:\Python22\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py",
line 307, in RunScript
    debugger.run(codeObject, __main__.__dict__, start_stepping=0)
  File "C:\Python22\lib\site-packages\Pythonwin\pywin\debugger\__init__.py",
line 60, in run
    _GetCurrentDebugger().run(cmd, globals,locals, start_stepping)
  File "C:\Python22\lib\site-packages\Pythonwin\pywin\debugger\debugger.py",
line 591, in run
    exec cmd in globals, locals
  File "C:\Documents and Settings\mcelroyj.FACILITY9.000\Desktop\lookup.py",
line 39, in ?
    result_list = b.Send( u, 'GetEEMeaning', DictRequest(word) )
  File "C:\Python22\Lib\site-packages\ZSI\client.py", line 175, in Send
    self.h.connect()
  File "C:\Python22\lib\httplib.py", line 516, in connect
    socket.SOCK_STREAM):
gaierror: (7, 'getaddrinfo failed')

The source follows.  I'm fairly new to using web services in Python, and I
have only found very limited information on using them, so I'm extrapolating
what I can from the docs.

Thanks,

Jeremiah

SOURCE:

#!/usr/bin/env python

import sys
import xml
from ZSI import TC
from ZSI.client import Binding

FULL_DICT_NS = "http://www.xceer.com/trans/dic2.asmx?WSDL"

u = '/trans/dic2.asmx?WSDL'
h = 'http://www.xceer.com'
n = 'http://tempuri.org/'
SOAPMethod = 'GetEEMeaning'
SoapAction = n + SOAPMethod
dict = {
    'xmlns:xsi' : 'http://www.w3.org/2001/XMLSchema-instance',
    'xmlns:xsd' : 'http://www.w3.org/2001/XMLSchema',
    'xmlns:soap': 'http://schemas.xmlsoap.org/soap/envelope/'
    }
b = Binding( url=u, host=h, port=80, ns=n, nsdict=dict,
soapaction=SOAPMethod )

try:
    word = sys.argv[1]
except IndexError:
    print 'No word given, looking up "curmudgeon"'
    word = 'curmudgeon'

class DictRequest:
    def __init__( self, word ):
        self.englishWord = word

DictRequest.typecode = TC.Struct(DictRequest,
                                 [TC.String('englishWord')],
                                 'GetEEMeaning',
                                 inline=1)

try:
    result_list = b.Send( u, 'GetEEMeaning', DictRequest(word) )

    print "result_list: ", result_list
except:
    raise
    print 'reply     : ', b.reply_code
    print 'reply_msg : ', b.reply_msg
    print 'headers   : ', b.reply_headers
    print 'data      : ', b.data







More information about the Python-list mailing list