使用 SUDS 测试 WSDL

发布于 2024-08-17 19:30:49 字数 1040 浏览 6 评论 0原文

有谁知道一个好的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

尘世孤行 2024-08-24 19:30:49

Suds 使用起来非常简单。

from suds.client import Client

client = Client("http://example.com/foo.wsdl")
client.service.someMethod(someParameter)

someMethod 是 WSDL 中描述的方法的名称。

Suds is very simple to use.

from suds.client import Client

client = Client("http://example.com/foo.wsdl")
client.service.someMethod(someParameter)

someMethod is the name of a method as described in the WSDL.

再见回来 2024-08-24 19:30:49

连接被拒绝表明服务器不存在。您可以在浏览器中或通过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.

好听的两个字的网名 2024-08-24 19:30:49

就我而言,这是一个愚蠢的错误(就像任何其他错误一样)。

我用来初始化服务的 URL 类似于

Uri httpUri = new Uri("http://localhost:8000/CalculatorService");

我可以从与该服务运行在同一台计算机上的 python 客户端访问该服务。我可以从本地和远程计算机上的浏览器浏览 wsdl。但是,当我尝试从远程计算机访问此服务时,出现连接拒绝错误。奇怪的是,在wireshark中,我可以看到该服务将wsdl发送回远程客户端。
浪费了几个小时后,我启用了日志记录。

logging.getLogger('suds.client').setLevel(logging.DEBUG)
logging.getLogger('suds.transport').setLevel(logging.DEBUG)
logging.getLogger('suds.xsd.schema').setLevel(logging.DEBUG)
logging.getLogger('suds.wsdl').setLevel(logging.DEBUG)

日志显示 suds 从服务器下载了 wsdl,但之后它尝试连接到 localhost:8000。这解释了连接拒绝错误。我刚刚将 WCF 服务器上的 URI 更改为

Uri httpUri = new Uri("http://192.168.0.1:8000/CalculatorService");

这解决了我的问题

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

Uri httpUri = new Uri("http://localhost:8000/CalculatorService");

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

logging.getLogger('suds.client').setLevel(logging.DEBUG)
logging.getLogger('suds.transport').setLevel(logging.DEBUG)
logging.getLogger('suds.xsd.schema').setLevel(logging.DEBUG)
logging.getLogger('suds.wsdl').setLevel(logging.DEBUG)

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

Uri httpUri = new Uri("http://192.168.0.1:8000/CalculatorService");

And that solved my problem

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文