我非常绝望......我的代码中不能使用suds ......我试试这个
#!/usr/bin/python2
import suds
url = "http://scsadx02:8080/lrs/webconnect/vpsx?trid=vpsx"
client = suds.client.Client(url)
Server = client.factory.create("ns0:string")
Serverin = client.factory.create("ns0:string")
UserID = client.factory.create("ns0:string")
Password = client.factory.create("ns0:string")
NewPassword = client.factory.create("ns0:string")
Server.value = 'SPLVSVK2'
Serverin.value = 'SPLVPSK2'
UserID.value = 'serviceudp'
Password.value = 'dpuecivres'
NewPassword.value = ''
#method I have to call
#Suds ( https://fedorahosted.org/suds/ ) version: 0.4 GA build: R699-20100913
#
#Service ( VPSXService ) tns="http://www.lrs.com"
# Prefixes (2)
# ns0 = "http://schemas.xmlsoap.org/soap/encoding/"
# ns1 = "http://www.lrs.com"
# Ports (1):
# (VPSXPort)
# Methods (95):
# Logoff(xs:string SessID, )
# Logon(xs:string Server, xs:string UserID, xs:string Password, xs:string NewPassword, )
client.service.Logon(Server, UserID, Password, NewPassword)
但我得到了这个错误...
[davide@archy PYTHON]$ ./testina.py
Traceback (most recent call last):
File "./testina.py", line 31, in <module>
client.service.Logon(Server, UserID, Password, NewPassword)
File "/usr/lib/python2.7/site-packages/suds/client.py", line 542, in __call__
return client.invoke(args, kwargs)
File "/usr/lib/python2.7/site-packages/suds/client.py", line 602, in invoke
result = self.send(soapenv)
File "/usr/lib/python2.7/site-packages/suds/client.py", line 637, in send
reply = transport.send(request)
File "/usr/lib/python2.7/site-packages/suds/transport/https.py", line 64, in send
return HttpTransport.send(self, request)
File "/usr/lib/python2.7/site-packages/suds/transport/http.py", line 77, in send
fp = self.u2open(u2request)
File "/usr/lib/python2.7/site-packages/suds/transport/http.py", line 118, in u2open
return url.open(u2request, timeout=tm)
File "/usr/lib/python2.7/urllib2.py", line 404, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 422, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1214, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1184, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error [Errno -2] Name or service not known>
我如何解决???
答案 0 :(得分:0)
尝试
C:\Python27>python -c "import urllib2; print urllib2.urlopen('http://scsadx02:8080/lrs/webconnect/vpsx?trid=vpsx').read()"
and import os; os.environ['http_proxy']=''
在导入其他模块之前。