我有一个简单的suds webservice客户端,一直运行良好。然而,无论什么时候我运行它,我现在得到“urllib2.URLError:”。请注意,我可以成功ping远程主机,也可以远程主机端口上telnet。我可以检查哪些事情来解决这个问题?以下是我的代码段:
from suds.client import Client
from suds.wsse import *
security = Security()
token = UsernameToken('user', 'pass')
token.setnonce()
token.setcreated()
security.tokens.append(token)
def func():
someVar = '2222222'
try:
url ='http://IP:Port/SomeWebServices/service?wsdl'
client = Client(url)
return client.service.SomeMeth(someVat)
except Exception,x:
raise x
if __name__ == '__main__':
response = func()
print response['responseCode']
print response['balance']
答案 0 :(得分:5)
也许你可以试试:
url ="your?wsdl"
client = Client(url,cache=None)
client.set_options(location=url) // new line
return client.service.SomeMeth(someVat)