使用 SUDS 测试 WSDL
有谁知道一个好的 SUDS 教程。我正在尝试对 WSDL 文件运行测试,但无法找到有关如何执行此操作的任何信息。 SUDS 与 SOAPy 有很大不同吗?有人会推荐它对 WSDL 文件中存储的函数运行冒烟测试吗?
我读到 Python 2.6+ 不再支持 SOAPAy。这是真的吗?
我输入了一个 WSDL 文件:
from suds.client import Client
client = Client('http://10.51.54.50/ptz.wsdl')
client.service.GetNode()
我收到此错误:
in open
response = self._open(req, data)
File "/home/build/workspace/downloads/Python-2.6.4/Lib/urllib2.py", line 407, in _open
'_open', req)
File "/home/build/workspace/downloads/Python-2.6.4/Lib/urllib2.py", line 367, in _call_chain
result = func(*args)
File "/home/build/workspace/downloads/Python-2.6.4/Lib/urllib2.py", line 1146, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/home/build/workspace/downloads/Python-2.6.4/Lib/urllib2.py", line 1121, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error [Errno 111] Connection refused>
有谁知道为什么会发生这种情况?
我可以通过浏览器连接到该文件。我已经安装了所有的 suds 软件包。还需要其他设置吗?
Does anyone know about a good SUDS tutorial. I am trying to run tests on WSDL files and I am having trouble finding any imformation on how to do this. Is SUDS much different to SOAPy and would anyone recommend it to run smoke tests on functions stored in WSDL files.
I have read that SOAPAy is no longer supported in Python 2.6+. Is this true?
I have a WSDL file I have entered:
from suds.client import Client
client = Client('http://10.51.54.50/ptz.wsdl')
client.service.GetNode()
I got this error:
in open
response = self._open(req, data)
File "/home/build/workspace/downloads/Python-2.6.4/Lib/urllib2.py", line 407, in _open
'_open', req)
File "/home/build/workspace/downloads/Python-2.6.4/Lib/urllib2.py", line 367, in _call_chain
result = func(*args)
File "/home/build/workspace/downloads/Python-2.6.4/Lib/urllib2.py", line 1146, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/home/build/workspace/downloads/Python-2.6.4/Lib/urllib2.py", line 1121, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error [Errno 111] Connection refused>
Does anyone know why this is happening?
I can connect to this file through my browser. I have installed all the suds packages. Is there any other setup required?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Suds 使用起来非常简单。
someMethod
是 WSDL 中描述的方法的名称。Suds is very simple to use.
someMethod
is the name of a method as described in the WSDL.连接被拒绝表明服务器不存在。您可以在浏览器中或通过curl访问http://10.51.54.50/ptz.wsdl吗?如果没有,请首先运行 SOAP 服务,然后重试。
Connection refused indicates that the server isn't there. Can you access http://10.51.54.50/ptz.wsdl in a browser or via curl? If not, start by getting the SOAP service running first then try again.
就我而言,这是一个愚蠢的错误(就像任何其他错误一样)。
我用来初始化服务的 URL 类似于
我可以从与该服务运行在同一台计算机上的 python 客户端访问该服务。我可以从本地和远程计算机上的浏览器浏览 wsdl。但是,当我尝试从远程计算机访问此服务时,出现连接拒绝错误。奇怪的是,在wireshark中,我可以看到该服务将wsdl发送回远程客户端。
浪费了几个小时后,我启用了日志记录。
日志显示 suds 从服务器下载了 wsdl,但之后它尝试连接到 localhost:8000。这解释了连接拒绝错误。我刚刚将 WCF 服务器上的 URI 更改为
这解决了我的问题
In my case it was a stupid mistake ( just like any other bug).
The URL that I had used to initialize my service was something like
I could access this service from a python client running on the same machine as the service. I could browser the wsdl from a browser both locally and from a remote machine. However when I tried to access this service from a remote machine, I got connection refused error. The strange thing was that in wireshark, I could see that the service sends back the wsdl to the remote client.
After wasting a couple of hours, I enabled logging
The logs showed that suds downloaded the wsdl from the server but after that it tried to connect to localhost:8000. And that explained the connection refused error. I just changed the URI on the WCF server to
And that solved my problem