求助:DiveIntoPython的一段代码运行错误,请大家帮忙看看。。。

求助:DiveIntoPython的一段代码运行错误,请大家帮忙看看。。。

环境:WinXP SP2,Python 2.4.2,又安装了SOAPpy-0.11.6.zip, fpconst-0.7.2.zip,PyXML-0.8.4.win32-py2.4.exe。

代码是按照《DiveIntoPython》的《Example 12.11. Calling A Web Service Through A WSDL Proxy》写的。

下面是在IDLE 1.1.2运行的结果,请大家帮忙看看问题所在:

>>> from SOAPpy import WSDL
>>> wsdlFile = 'http://www.xmethods.net/sd/2001/TemperatureService.wsdl'
>>> server = WSDL.Proxy(wsdlFile)
>>> server.methods.keys()
[u'getTemp']
>>> server.getTemp('90210')

Traceback (most recent call last):
  File "<pyshell#4>", line 1, in -toplevel-
    server.getTemp('90210')
  File "E:\Program Files\Python\Lib\site-packages\SOAPpy\Client.py", line 453, in __call__
    return self.__r_call(*args, **kw)
  File "E:\Program Files\Python\Lib\site-packages\SOAPpy\Client.py", line 475, in __r_call
    self.__hd, self.__ma)
  File "E:\Program Files\Python\Lib\site-packages\SOAPpy\Client.py", line 347, in __call
    config = self.config)
  File "E:\Program Files\Python\Lib\site-packages\SOAPpy\Client.py", line 187, in call
    r.endheaders()
  File "E:\Program Files\Python\lib\httplib.py", line 795, in endheaders
    self._send_output()
  File "E:\Program Files\Python\lib\httplib.py", line 676, in _send_output
    self.send(msg)
  File "E:\Program Files\Python\lib\httplib.py", line 643, in send
    self.connect()
  File "E:\Program Files\Python\lib\httplib.py", line 611, in connect
    socket.SOCK_STREAM):
gaierror: (11001, 'getaddrinfo failed')
>>>
直接用你的浏览器访问http://www.xmethods.net/sd/2001/TemperatureService.wsdl,看看可以不?
谢谢wolfg,问题已经解决。

以前我是在IE里面手动设置代理服务器来上网,但会有我上面说的问题。
现在装了个MSFireWallClient就一切OK了,它会自动连接代理服务器,不用在IE里面设置了。
ie的proxy设置管不到python
See the documentation for urllib.urlopen:

"""
In a Windows environment, if no proxy environment variables are set,
proxy settings are obtained from the registry's Internet Settings
section.
"""