Convert SOAP service to REST API
Intermediate | 45 Minutes
API Gateway Enterprise Integration
Overview
You want to integrate Infor OS with another system using APIs, but the system only supports SOAP web services, while Infor OS prefers REST APIs. How can you create a modern, integrated solution?
📋 Requirements
|
Tutorial
SOAP Web Services are still a valid option in the API world. They are based on WSDL (Web Service Definition Language), an XML file where you define the input and output with message types. This approach differs from REST (Representational State Transfer), which is based on Swagger documentation 2.0 or Open API 3.0.x.
Since ION API connectors are based on REST, SOAP web services cannot be used directly. Instead, we convert SOAP to REST using API Policies.
Register custom API suite
We can convert a SOAP web service into a REST API using API Policies and the following WSDL:
https://www.dataaccess.com/webservicesserver/numberconversion.wso?WSDL
Once we have the URL (Uniform Resource Locator) of the WSDL we can register a new custom API suite in the API Gateway.
Login to OS Portal and click on API Gateway. Click the (+) Add button.
Click on Create New button.
Input the following values and under the Target Endpoints tab, click the + button
On the Add Endpoint page, in the Target Endpoint URL field enter the WSDL URL. Enter rest in the Proxy Context field. Click Save.
https://www.dataaccess.com/webservicesserver/numberconversion.wso?WSDL
Below is the output screen after Save.
Upload swagger documentation
We need swagger documentation or an Open API 3.0.x to document our endpoint, which can be found with the following link or under the Downloads sections at the bottom the tutorial (Swagger file to import into API Gateway). This file needs to be uploaded into the API suite.
Click on the Details button for the rest Endpoint you just created.
Scroll to the bottom of the rest endpoint page and select the Documentation tab. Click the (+) button.
Download and extract the swagger.zip file from the Swagger file to import into API Gateway link in the Download section.
On the Add Documentation page, in the Name field type rest, from the drop down select Swagger in the Type field. Click the browse button on the Enter URL or Upload Swagger JSON/YAML field and select the rest.json file that was extracted from the swagger.zip file.
Add documentation:
- Click on the Details button for the REST endpoint.
- Scroll to the Documentation tab and click ( + ) Add.
- Extract the
swagger.zipfile. - Upload the
rest.jsonfile extracted fromswagger.zip. - Click Save.
Click Save.
Below is the output screen after Save.
Create request and response policies
Defining the Endpoint Policy for Request and Response. We have to write the scripts that convert JSON input from REST API to XML (Request) and SOAP that converts XML to JSON as a (Response).
Request Policy (JSON to XML)
Response Policy (XML to JSON)
Scroll to the bottom of the rest endpoint page. Select the Endpoint Policies tab and click the (+) button under Request Policies.
From the drop down select Transformation for the Policy Type field, in the Name field type input. For the Policy Definition replace the content with the From JSON to XML request script information displayed in a previous step. Click Save.
Go back to the rest endpoint page and under the Endpoint Policies tab click the (+) button under Response Polices.
From the drop down select Transformation for the Policy Type field, in the Name field type output. For the Policy Definition replace the content with the From XML to JSON response script information displayed in a previous step. Click Save.
Below is the output screen after Save.
Test API
On the rest Endpoint page, select the Documentation tab and click the POST button, then click the Try it out button,
Change the number value from string to 101 and click the Execute button.
In the Response Body you should see the results, notice the one hundred and one content is displayed. This is telling you it is working.
Test ION API connection point
Go to the ION tab, expand Connect and select Connection Points. Click on the (+) Add button.
From the drop down, select API.
In the Name field type soap2rest_cp, click the IMPORT button to import your Service Account. Select the folder button and select your ServiceAccount csv file that was generated when creating a service account..
Click Ok.
Below is the output screen after Ok.
Select the Documents tab and click the (+) button. Click on the SELECT button at the bottom of the screen.
From the drop down select soap to rest.
Select the search button and select the CustomerAPI/soap/rest API. Click Ok.
In the API Call Name field type soap.
Select the Request Body tab and click on the EXAMPLE button. You will change the string number value to 101.
Select the Output Documentation tab and select the Document search button. Search and select the AnyDocuments option, click Ok.
Click the TEST button, you will receive the Warning message, click Yes.
Click the Test button.
You will notice the Output displaying the one hundred and one message. This tells us the API call is working and the Soap to REST conversion is successful.
What made this section unhelpful for you?
On this page
- Convert SOAP service to REST API