开发者

Using SUDS to test WSDL

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 functi开发者_如何学编程ons 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?


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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜