简体   繁体   English

使用SUDS测试WSDL

[英]Using SUDS to test WSDL

Does anyone know about a good SUDS tutorial. 有谁知道一个很好的SUDS教程。 I am trying to run tests on WSDL files and I am having trouble finding any imformation on how to do this. 我试图在WSDL文件上运行测试,我无法找到有关如何执行此操作的任何信息。 Is SUDS much different to SOAPy and would anyone recommend it to run smoke tests on functions stored in WSDL files. SUDS与SOAPy有很大的不同吗?任何人都建议它对存储在WSDL文件中的函数运行冒烟测试。

I have read that SOAPAy is no longer supported in Python 2.6+. 我已经读过Python 2.6+不再支持SOAPAy。 Is this true? 这是真的?

I have a WSDL file I have entered: 我有一个我输入的WSDL文件:

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? 是否还需要其他设置?

Suds is very simple to use. Suds非常简单易用。

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. someMethod是WSDL中描述的方法的名称。

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 我用来初始化我的服务的URL是这样的

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. 我可以从与服务在同一台机器上运行的python客户端访问此服务。 I could browser the wsdl from a browser both locally and from a remote machine. 我可以在本地和远程计算机上浏览浏览器中的wsdl。 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. 奇怪的是,在wireshark中,我可以看到服务将wsdl发送回远程客户端。 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. 日志显示suds从服务器下载了wsdl,但之后它尝试连接到localhost:8000。 And that explained the connection refused error. 这解释了连接拒绝错误。 I just changed the URI on the WCF server to 我刚刚将WCF服务器上的URI更改为

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

And that solved my problem 这解决了我的问题

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? 你可以在浏览器中或通过curl访问http://10.51.54.50/ptz.wsdl吗? If not, start by getting the SOAP service running first then try again. 如果没有,首先运行SOAP服务然后再试一次。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM