What is the alternative to SUDS?

I used to use SUDS to retrieve data from Web services, but now that it’s no longer included with Ignition, and development.

Is anyone out there using an alternative to SUDS?

What are my options?

It’s quite easy to use plain HTTP requests and parse the XML with python. If you know the format.

Otherwise, I believe SUDS is a pure-python module, so you can install it yourself by placing the module in user-lib/pylib in your ignition install directory.

1 Like

SUDS is just a python module module as Sanderd17 mentioned, unfortunately that module seemed pretty much dead when I tried to use it last year. Original documentation pretty much said so and look for a fork of it. I had trouble getting it to work 100% with an ERP web service and due to time constraints and lack of good documentation for it I splurged and picked up the Sepasoft Web Services module and use that instead.

However my google-fu got me:

https://bitbucket.org/jurko/suds/wiki/Original%20Documentation

So looks like someone recently brought some life back into SUDS, well at least the documentation.

I’m happy with the Sepaosft Module, the original version of it was clearly just a SUDS wrapper to make it easy to configure from Ignition, but the latest module looks to be built from the ground up. I did run into an issue with the Sepasoft module and trying to connect to an ERP web service that was configured with nested WSDL files. I wouldn’t call it a Sepasoft issue at all, really a change in .NET programming and Java compatibility as I understand it. As long as you get a single WSDL with all definitions it works great.

1 Like

Parsing XML with the Etree Library:
https://docs.inductiveautomation.com/display/DOC79/Parsing+XML+with+the+Etree+Library

Thank you all for your suggestions.

@Sanderd17:
In the past I have copied the suds folder, but I worry about compatibility with future releases.

Would you care explaining how to use plain HTTP requests against a Web service?

@Paullys50:
Thank you, but a $3,500 USD module is not exactly the solution I’m currently seeking.

@R.Alamsha
How would you use the Etree library to call a Web service method?

Understandable but you did ask for an alternative, and with the module you’ll have it working in a fraction of the time. As I said my luck with SUDS was no bueno (would throw schema errors which I believe was due to a problematic WSDL from the ERP system) and I couldn’t find an obvious ‘free’ alternative to SUDS.

The link I provided takes you to what you need to get started so you can try SUDS and see if it does what you need.

Etree doesn’t call a web service, it just allows you to parse the related XML should you need to decode a result from the web service.

Do you have to pull data from the Web Service? Or publish data to the Web Service?

1 Like

Pull data from a Web service.

I have an application using SUDS, and it is working just fine. I do remember I was experiencing a problem with the WSDL, so I switched to the Single WSDL.

The service I am using offers these two options:
http://server/dataservice/service.svc?wsdl
and
http://server/dataservice/service.svc?singleWsdl

Using the latter solved whatever problem I was having, by calling the desired method like this:

from suds.client import Client
client = Client('http://server/dataservice/service.svc?singleWsdl')
result = client.service.Method(param1, param2, ...)
1 Like

Can you pull the data as JSON and process it further?.

I’ve used SoapUI before to examine a SOAP wsdl: https://www.soapui.org/

Basically, when you call a SOAP function, it sends a HTTP request like server/path/to/soapInstallation/SoapFunction?Param1=xxx&Param2=yyy SoapUI should show you the correct url to query.

You can directly call this using the httpGet method (including authentication): https://docs.inductiveautomation.com/display/DOC/system.net.httpGet

Then usually, the answer is an XML document, which you can parse with Etree or any other XML parser in pure python.

Another note on the compatibility on SUDS: it will work as long as Ignition keeps using Python 2.x. Given that Jython doesn’t even have a 3.x version released, I assume it will still be usable a few decades.

1 Like

I hope to help change that, with my copious free time… /-:

1 Like

… that’s how I feel about my “free time”, anyway …

3 Likes

After playing around with SoapUI I was able to get the SOAP envelope for my POST request, which in turn I used as a parameter for the system.net.httpPost method.

I got the headers by looking at the Raw representation of the SOAP request in SoapUI.

Here is my sample code in case anyone may be interested:

dataservice = 'http://webserver/dataservice/service.svc'
soapenv = u"""<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:Method>
         <!--Optional:-->
         <tem:param1>test</tem:param1>
      </tem:Method>
   </soapenv:Body>
</soapenv:Envelope>"""

headers = {
	'Content-Type': 'text/xml;charset=UTF-8',
	'SOAPAction': 'http://tempuri.org/service/Method',
	'Content-Length': len(soapenv),
	'Host': 'webserver',
	'Connection': 'Keep-Alive',
	'User-Agent': 'Ignition'
}

response = system.net.httpPost(url=dataservice, contentType='text/xml', postData=soapenv, headerValues=headers)

In this example the response variable will hold the XML response from the Web service.

Cheers!

3 Likes