Using an SOA gateway like SecureSpan SOA Gateway to perform REST to SOAP transformation at runtime is trivial to setup. With SecureSpan in front of any existing web service (in the DMZ for example), you can virtualize a REST version of this same service. Using an example, here is a description of the steps to perform this conversion.
Imagine the geoloc web service for recording geographical locations. It has two methods, one for setting a location and one for getting a location. See below what this would look like in SOAP.
Here is the equivalent REST target that I want to support at the edge. Payloads could be XML, but let’s use JSON to make it more interesting.
Now let’s implement this REST version of the service using SecureSpan. I’m assuming that you already have a SecureSpan SOA Gateway deployed between the potential REST requesters and the existing SOAP web service.
First, I will create a new service endpoint on the gateway for this service and assign anything that comes at the URI pattern /position/* to this service. I will also allow the HTTP verbs GET and POST for this service.
REST geoloc service properties
Next, let’s isolate the resource id from the URI and save this as a context variable named ‘trackerid’. We can use a simple regex assertion to accomplish this. Also, I will branch on the incoming HTTP verb using an OR statement. I am just focusing on GET and POST for this example but you could add additional logic for other HTTP verbs that you want to support for this REST service.
Regex for REST service resource identification
Policy branching for GET vs POST
For GET requests, the transformation is very simple, we just declare a message variable using a SOAP skeleton into which we refer to the trackerid variable.
SOAP request template
This soap message is routed to the existing web service and the essential elements are isolated using XPath assertions.
Processing SOAP response
The REST response is then constructed back using a template response.
Template JSON response
A similar logic is performed for the POST message. See below for the full policy logic.
You’re done for virtualizing the REST service. Setting this up with SecureSpan took less than an hour, did not require any change on the existing SOAP web service and did not require the deployment of an additional component. From there, you would probably enrich the policy to perform some JSON schema validation, some URL and query parameter validation, perhaps some authentication, authorization etc.