1

因此,我正在使用 python 中的应用程序的 url 进行基本的 Web 服务调用。我只是在测试连接以查看 Web 服务是否响应。我的代码如下:

from suds.client import Client

client = Client("File:///C:/Users/zsssss/Documents/TrannsTubalService.wsdl")

print client

但是,我不断收到如下错误:

pydev debugger: starting
Traceback (most recent call last):
File "C:\Users\zsssss\AppData\Local\Aptana Studio 3\plugins\org.python.pydev_2.7.0.2013012902\pysrc\pydevd.py", line 1397, in <module>
debugger.run(setup['file'], None, None)
File "C:\Users\zsssss\AppData\Local\Aptana Studio 3\plugins\org.python.pydev_2.7.0.2013012902\pysrc\pydevd.py", line 1090, in run
pydev_imports.execfile(file, globals, locals) #execute the script
File "C:\Users\zsssss\My Documents\Aptana Studio 3 Workspace\sudsclient\src\transtube.py", line 7, in <module>
client = Client("File:///C:/Users/zn483d/Documents/TrannsTubalService.wsdl")
File "C:\Python27\lib\site-packages\suds\client.py", line 112, in __init__
self.wsdl = reader.open(url)
File "C:\Python27\lib\site-packages\suds\reader.py", line 152, in open
d = self.fn(url, self.options)
File "C:\Python27\lib\site-packages\suds\wsdl.py", line 159, in __init__
self.build_schema()
File "C:\Python27\lib\site-packages\suds\wsdl.py", line 220, in build_schema
self.schema = container.load(self.options)
File "C:\Python27\lib\site-packages\suds\xsd\schema.py", line 93, in load
child.open_imports(options)
File "C:\Python27\lib\site-packages\suds\xsd\schema.py", line 305, in open_imports
imported = imp.open(options)
File "C:\Python27\lib\site-packages\suds\xsd\sxbasic.py", line 542, in open
result = self.download(options)
File "C:\Python27\lib\site-packages\suds\xsd\sxbasic.py", line 560, in download
d = reader.open(url)
File "C:\Python27\lib\site-packages\suds\reader.py", line 79, in open
d = self.download(url)
File "C:\Python27\lib\site-packages\suds\reader.py", line 95, in download
fp = self.options.transport.open(Request(url))
File "C:\Python27\lib\site-packages\suds\transport\https.py", line 60, in open
return  HttpTransport.open(self, request)
File "C:\Python27\lib\site-packages\suds\transport\http.py", line 62, in open
return self.u2open(u2request)
File "C:\Python27\lib\site-packages\suds\transport\http.py", line 118, in u2open
return url.open(u2request, timeout=tm)
File "C:\Python27\Lib\urllib2.py", line 400, in open
response = self._open(req, data)
File "C:\Python27\Lib\urllib2.py", line 418, in _open
'_open', req)
File "C:\Python27\Lib\urllib2.py", line 378, in _call_chain
result = func(*args)
File "C:\Python27\Lib\urllib2.py", line 1310, in file_open
return self.open_local_file(req)
File "C:\Python27\Lib\urllib2.py", line 1350, in open_local_file
raise URLError(msg)
urllib2.URLError: <urlopen error [Error 2] The system cannot find the file specified: u'C:\\Users\\zsssss\\Documents\\TrannsTubalResponse.xsd'>
4

1 回答 1

0

有点老问题,但有同样的问题。为此,我使用了 pathlib:

import pathlib
filepath = '/var/www/yourwsdlfile.extension'
fileuri = pathlib.Path(filepath).as_uri()
client = Client(url=fileuri)

在 Ubuntu 上使用 suds-jurko 0.6 为我工作。我注意到我的 fileuri 最终成为 'file:///var/www/secureitemdelivery.asmx'

于 2015-11-19T09:10:22.107 回答