Using SUDS to test WSDL
Asked Answered
I

3

7

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?

Ingmar answered 14/1, 2010 at 11:27 Comment(4)
urlopen error [Errno 111] Connection refused sounds like you are not allowed to access the IP.Diversification
No, additonal setup is not required.Diversification
were you able to develop the suds based test framework ? if so , did your result have junit type XML format ?Seraphic
@Seraphic - I got the smoke test working with suds. I used unittest with suds. If you look at some of my suds based answers you can see what was used.Ingmar
D
17

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.

Diversification answered 14/1, 2010 at 11:36 Comment(0)
S
2

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.

Sufferable answered 14/1, 2010 at 12:1 Comment(0)
C
2

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

Chemism answered 20/11, 2013 at 10:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.