How to call SOAP services using REST

Reading time: 4 minutes

SOAP, being a mature technology, has an extensive and often differently interpreted standard set. This makes it an excellent tool for corporate users to manipulate data into their precise requirements and technology stack. However, for public consumption, this causes issues that sometimes are difficult or impossible to solve without changing code.  A good example is that SOAP can define the same type in standard interpretations in different XSD files. However, when trying to use this in other interpreters, it will most likely crash.

We need to look at SOAP a little bit deeper to solve this. In essence, SOAP, as a technology, is simply a Web (or HTTP) POST call with a specifically formatted XML payload, which the SOAP server is expecting and understands. It then returns a specifically formatted XML response that the client can parse and use.

You might be saying, ‘Hey, that sounds like a REST call,’ but that is exactly what it is. Instead of an API reference, which gives you the Request and Response formats and requirements, SOAP publishes a WSDL. So if you’ve got one of these SOAP Services which breaks standards, if you can get the text of a successful Request, you can use REST to make the call with that request body. I will use a free SOAP web service that works with countries to show you how this works.

Linx uses .NET services to call SOAP services, following the .Net defined standards. This means that there would be SOAP services that would not work with Linx directly, as they would break the .NET standards for SOAP.

This example works fine with the SOAP Plugin, but to show the REST option, let’s imagine that it will break and we need to use REST to call it.

Let’s start:

First, we’ll use a tool like SoapUI or Postman to try and get a successful call. Alternatively, if you are already given a successful payload, like in this example, you can use that (Example Documents for CountryInfoService).

To get started, add a new SOAP Project to SoapUI and add the WSDL. We first test if SoapUI gets a successful response back. SoapUI Screenshot of the required payload (SoapUI gave us ? parameters, which we just changed to logical values) and a successful response:

Required Payload and Successful Response

Now we can set up Linx with a CallRESTWebService function and call the SOAP service.

Note: Sometimes, as in this example, the SOAP server requires specific Content-Types. Use your successful call from SoapUI to find these instances. In this example, the SOAP server wanted a content type of ‘text/xml;charset=UTF-8’ and did not accept the default ‘application/xml’.  So we just added in a Header to overwrite the content type.


SOAP with REST Call

The screenshot above shows that we used the ‘CallRESTEndpoint‘ function to call the SOAP Web service. You can now easily extend this process to your other target systems.

You need to ensure that the body is correctly passed to the SOAP web service in order for this to work.

Try it! Download and test the Linx Solution.

Here is a small breakdown of what is happening in the Linx solution:

  1. Set the values in the XMLPayload
  2. Call the SOAP endpoint via a REST call. Note the call is being made as a POST with the XMLPayload set as the request body. The content type is also set in the header. Set the response body to be string as we want to receive the XML string as is.
  3. A XMLReader will make it easier for us to interact and extract values from the XML Response. It is important to remove any instances of “soap:” and “m:” from the string in order for Linx to be able to read the XML.

Low-code API development guides

  • Design-first using an OpenAPI specification
  • Code-first API builder, fast implementation, including hosting and documentation 

Sign up to our Newsletter