在 Web 服务通信中出现 URLOpen 错误
我需要开发一个应用程序,这个程序要通过Python和一个网络服务进行通信。由于某些原因,我必须在Windows服务器上运行这段代码(我对这个系统不太熟悉,通常我们使用的是基于Unix的系统)。
我和API提供商的沟通不是直接的,因为有一些沟通上的问题。所以我需要把我的问题发邮件给另一个人,然后他再用原语言把我的信息发给他们。因此,我无法从提供商那里获得太多支持。
我的问题是,我使用suds
作为网络服务客户端。客户端似乎成功地从服务器获取了WSDL定义,内容像这样:
from suds.client import Client
class SomeClass(Client):
def __init__(self):
Client.__init__(url)
def myFunc():
f = SomeClass()
print f
服务(传输)tns="..."
前缀(1)ns0 = ....
Ports (2): (TransportSoap) Methods (4) GetBalance()
...
所以我可以看到suds
能够连接到目标网络服务并获取WSDL文件。然而,当我调用一个方法时,比如:
def myFunc():
f = SomeClass()
f.GetBalance()
Urllib2.URLError <urlopen error [Errno 10060] A connection attempt
failed because the connected party did not properly respond after a
period of time, or established connection failed because connected
host has failed to respond>
我看不出哪里出错了?
1 个回答
0
经过一番搜索,发现了 urlopen error [Errno 10060]
这个问题后,我决定尝试使用代理,结果这真的是解决办法!
如果 WSDL 的网址是:
那么使用:
prxy = dict(http='http://someurl.com:1234/')
Client.set_options(proxy=prxy)
肯定能解决这个问题...