Blog

How to Turn Any SOAP Web Service into a REST API

Written by Terence Bennett | June 3, 2024

There are two types of remote web services: REST APIs and SOAP APIs

If you want to wrap a SOAP API and make it easier to work with through the use of REST endpoints, this simple tutorial will enable you to achieve that goal.

With this process, you'll be able to make a request with JSON to the API and receive a response in JSON instead of a long-winded XML format. In turn, your team will save time and cut out delays and frustration thanks to the simple and effective process that will result from this simple change.


Who Is This For?

The use case here is a team that has a SOAP API and wants to wrap that API in REST so that you can call it with ease.

There are many applications where you're likely to find this useful and, in fact, just about every team out there that works with such APIs will probably benefit from going through this simple process.

How To Convert SOAP to REST

The steps are truly very simple to follow.

#1 Locate The API

Begin by locating the API that you want to work with.

If starting from scratch, go to Create and select SOAP Service then fill in all the information. Give it a name, label, and a short description before making it active.

We're going to use an example named temp with the label Temperature and a short description explaining that it's a SOAP service capable of doing a temperature conversion.

#2 Define A WSDL URI

At the base level, all you really need to do is provide a WSDL URI in the Config tab for the service you are attempting to work with.

For our example, we'll use:

https://www.w3schools.com/xml/tempconvert.asmx?WSDL

This is a simple public one that you could use. It will give you a working web service wrapped with REST and live documented with Swagger.

#3 View The API Docs

Once you save your URI in DreamFactory, it will create live API docs in Swagger that are completely REST-based.

Scroll down the list and locate the API you're working with. When you click on it, some endpoints will appear. The number of endpoints you have available to you will depend on the specific API that you are working with.

Our example happens to have two endpoints, both of which we can use with ease directly in the DreamFactory dashboard.

#4 Utilize The Requests

With our example, we can do a quick Get request to see what's available. This will show us things like the calls we can make with our API.

In our example, we have two options. First, we can convert a given temperature with a Celsius to Fahrenheit conversion. The other option is to convert a temperature with a Fahrenheit to Celsius conversion.

Therefore, this option gives us two Post request options (Celsius to Fahrenheit or Fahrenheit to Celsius). Selecting one of these Post requests will populate the body post and enable us to get the information we need.

Why Use This Method?

You can probably already brainstorm a multitude of reasons why your team might choose to utilize this method. However, the two most obvious ones that stretch across the board are simplicity and security.

These are benefits that every single use case will see upon implementing this method into their workflow.

Simplicity

As you can see from our example, using this method makes things extremely simple. Not only are requests suddenly quick and easy, your APIs will be quickly locatable through the DreamFactory dashboard and so much simpler to manage for you and your team.

Overall, implementing this method to use with your APIs will make workflows so much faster for everyone who has to work with them regularly. This method negates the need for long-winded XML requests and makes managing your databases much more convenient and efficient overall.

Security

Beyond simplicity, another benefit of using this method is security. This security can be achieved through the role access functions.

Once you have wrapped your SOAP API, you can then have end users who have sessions and you can have any number of roles. Those users will have role associations for role-based access control.

To control this, head to Roles and select one from the list. Under the Access tab for a specific role, you can assign services to the role by pressing the + icon. Select the service from the drop-down list to assign it.

This gives you a number of security benefits when wrapping a SOAP API in REST endpoints with the DreamFactory system.

Transforming Data: Using DreamFactory’s Scripting Capabilities

Transforming data between SOAP and REST formats is a common requirement when integrating legacy systems with modern web applications. DreamFactory provides robust scripting capabilities that enable developers to manipulate and transform data easily. By leveraging DreamFactory’s scripting options, such as Node.js, PHP, and Python, you can create custom logic to handle the complexities of SOAP to REST conversions efficiently.

Why Transform Data?

SOAP and REST APIs often have different data formats and structures. SOAP uses XML for its message format, while REST typically uses JSON. To ensure seamless communication between these two API types, data must be transformed from one format to another. This transformation ensures compatibility and allows modern applications to interact with legacy SOAP services without issues.

Scripting in DreamFactory

DreamFactory supports server-side scripting in multiple languages, including Node.js, PHP, and Python. These scripts can be executed at various points in the API request/response lifecycle, allowing for flexible and powerful data transformations.

SOAP and REST Made Simple With DreamFactory

With this simple setup, you can basically take any WSDL and just put that WSDL URL in. Upon saving your settings, it will auto-generate the endpoints in Swagger. With that, your applications will simply be able to call that REST API whenever you put them to use. It does it all for you!

DreamFactory strives to make the process as simple and straightforward as possible. This tutorial should enable you to get everything setup and functioning correctly without any delays or hurdles. The steps are rather easy to follow so long as you do everything in the right order.

In addition to wrapping SOAP APIs with a REST endpoint, DreamFactory supports adding REST APIs on top of popular databases such as:

Frequently Asked Questions: Converting SOAP to REST

What are the steps to convert SOAP to REST using DreamFactory?

The steps are:

  • Locate the SOAP API you want to work with.
  • Define a WSDL URI for the API in the DreamFactory Config tab.
  • DreamFactory will generate live API docs in Swagger for your REST-based API.
  • Utilize the requests available in the generated API docs to interact with the SOAP API through REST endpoints.

What are the benefits of using REST endpoints?

Using REST endpoints offers simplicity and security. It simplifies API requests, making them quick and easy to manage. Additionally, security benefits can be achieved through role access functions, allowing control over user access to specific services.

How does DreamFactory enhance API management?

DreamFactory simplifies API management by providing a user-friendly dashboard where you can easily locate and manage your APIs. It transforms SOAP APIs into REST-based APIs with live API docs in Swagger, streamlining workflows and making databases more accessible and efficient.

Why is this method particularly useful for security?

When you wrap a SOAP API in REST endpoints with DreamFactory, you can implement role-based access control. This means you can assign different roles to end users and control their access to specific services, enhancing security and data protection.

What are the overall advantages of implementing this method with APIs?

The advantages include faster workflows, simplified API requests, enhanced security, and better management of APIs for your team. This method removes the complexity of dealing with long-winded XML requests and makes using and managing APIs more convenient for everyone involved.