RESTifying SOAP service using Kumologica
SOAP (Simple Object Access Protocol) is a standards-based web services access protocol that has been ruling the integration world for a long time. SOAP based web services was the de facto standard for SOA (Service Oriented Architecture). As the architecture moved from SOA to Microservices the enterprise started embracing the new philosophy from Roy Fielding which we call today as REST (Representational State Transfer). REST is an architectural style which relies on HTTP protocol without any support of higher level protocol like SOAP.
Below are major reasons for the popularity and motivation for moving from SOAP to REST:
- It was easy to represent any enterprise entity CRUD operations using REST principles as it uses HTTP protocol resource and methods.
eg : CRUD operation on database table named “Customer” can be represented as GET /customer, PUT /customer, DELETE /customer.
2. REST is relying on HTTP protocol directly rather that having an higher level protocol on top of it (like in case of SOAP). This reduces the network foot print during service invocation.
eg : For retrieving “customer” data from a database we use GET /customer/<<customerid>> whereas in case of SOAP we need a SOAP XML payload which is send to the server as HTTP POST call.
3. SOAP can only work with XML where as REST standard permits different data format such as Plain text, HTML, XML, JSON, etc.
SaaS or cloud native based platforms mostly use REST endpoints as the standard interfacing mechanism, be it for exposing the product features, or for enabling webhooks based integration. In order for integrating these platforms with the legacy systems running on enterprises that uses SOAP based interfaces it becomes difficult and hence we need RESTify the existing SOAP services.
In this article we will show you how easy it is to RESTify your SOAP service using Kumologica. For those who are new to Kumologica I would recommend to go through our articles and youtube videos to get an insight.
Use case
We have SOAP based calculator webservice hosted by a third party service provider (http://www.dneonline.com/calculator.asmx?WSDL). The service provides add, divide, multiply and subtract operations. This service needs to be RESTified for client consumption. The REST operations should be represented as given below.
Add operation
[GET] /calculator/add/1/2
subtract operation
[GET] /calculator/sub/1/2
Prerequisite
- Kumologica designer installed in your machine. https://kumologica.com/download.html
- Able to access the WSDL endpoint http://www.dneonline.com/calculator.asmx?WSDL
Implementation
Steps:
- Open Kumologica Designer, click the Home button and choose Create New Kumologica Project.
- Enter name (for example CalculatorFlow), select directory for project and switch Source into From Existing Flow …
- Copy and Paste the following flow
- press Create Button.
You should be seeing flow as given below on the designer canvas.
Understanding the flow
Add Flow
- GET /add is the EventListener node. It is configured to have the EventSource as Amazon API gateway. The node will have the following configuration.
verb: GET
URL : /calculator/add/:num1/:num2
2. Log is the Logger node to print the message in Amazon CloudWatch on entry of the flow.
Message: 'Request received ' & msg.header.event.Records[0].pathParameters.num1 & msg.header.event.Records[0].pathParameters.num2
3. Set-Property is the property node which is configured to prepare the payload to be send to the SOAP service. We will be using JSONata expression option from the drop down to set the payload.
Rules
Set msg.payloadto { "intA" : msg.header.event.Records[0].pathParameters.num1, "intB" : msg.header.event.Records[0].pathParameters.num2 }
4. Add is the SOAP node which will be invoking the SOAP service to add given two numbers and provide the result.
WSDL Url: http://www.dneonline.com/calculator.asmx
Method: Add
Timeout: 10000
Security: None
5. Success is the EventListener End node, the final node to complete the flow.
Status Code : 200
Content-Type : application/json
Payload : msg.payload
Subtraction flow
- GET /sub is the EventListener node. It is configured to have the EventSource as Amazon API gateway. The node will have the following configuration.
verb: GET
URL : /calculator/sub/:num1/:num2
2. Log is the Logger node to print the message in Amazon CloudWatch on entry of the flow.
Message: 'Request received ' & msg.header.event.Records[0].pathParameters.num1 & msg.header.event.Records[0].pathParameters.num2
3. Set-Property is the property node which is configured to prepare the payload to be send to the SOAP service. We will be using JSONata expression option from the drop down to set the payload.
Rules
Setmsg.payloadto{ "intA" : msg.header.event.Records[0].pathParameters.num1, "intB" : msg.header.event.Records[0].pathParameters.num2 }
4. Add is the SOAP node which will be invoking the SOAP service to add given two numbers and provide the result.
WSDL Url: http://www.dneonline.com/calculator.asmx
Method: Subtract
Timeout: 10000
Security: None
5. Success is the EventListener End node, the final node to complete the flow.
Status Code : 200
Content-Type : application/json
Payload : msg.payload
Deployment
- Select CLOUD tab on the right panel of Kumologica designer, select your AWS Profile.
- Set the Memory to 512mb and Timeout as 20 seconds.
- Go to “Trigger” section under cloud tab and select the Amazon API Gateway trigger.
Try it
- Invoke the following endpoint using the any REST client of your choice.
https://<<gateway instance id>>.execute-api.ap-southeast-2.amazonaws.com/test//calculator/add/1/2
You should get the response as given below
{
"AddResult" : 3
}
Conclusion
This article has shown how easy to REStify a SOAP service using Kumologica Designer.
Remember Kumologica is totally free to download and use. Go ahead and give it a try, we would love to hear your feedback.