Implementing an API Façade with the WSO2 API Management Platform
- Asanka Abeysinghe
- Chief Technology Officer, WSO2
[Based on a post originally appearing at https://asanka.abeysinghe.org.]
In my previous post I described about the reference architecture of API Façade. This post gives implementation details using the WSO2 API Management Platform and the WSO2 ESB.
Business scenario: A backend service with SOAP binding required to expose as a RESTful service and secured using OAuth. Consumers require responses in either XML or JSON using the same API.
Technical requirements: SOAP to REST protocol switching, content negotiation, XML to JSON conversion.
Reference architecture
Based on the recommended API Façade Pattern in my previous blog, the architecture looks like following diagram:
The API Gateway (Gateway is one of the roles in API Management Platform) will expose the RESTful API. The Mediation layer will do the protocol bridging and connect to a backend service with the SOAP binding.
Lets look at the implementation with WSO2 middleware products:
WSO2 API Manager and WSO2 ESB will be the primary middleware components used to build this Façade pattern.
Mediation logic (using standard EIP notations) looks like below.
API definition in API Manager (Gateway)
Mediation in ESB
Commands to Invoke the API
XML response :
curl -v -H "Authorization: Bearer zBAIbMiXR4AJjvWuyrCgGYgK2Osa" -X GET https://localhost:8280/ordersoap/1.0.0/view/JBLU
JSON response:
curl -v -H "Authorization: Bearer zBAIbMiXR4AJjvWuyrCgGYgK2Osa" -X GET https://localhost:8280/ordersoap/1.0.0/view/JBLU -H "Accept: application/json"
To view the JSON message properly in CMD
curl -v -H "Authorization: Bearer zBAIbMiXR4AJjvWuyrCgGYgK2Osa" -X GET https://localhost:8280/ordersoap/1.0.0/view/JBLU -H "Accept: application/json" | python -mjson.tool
In the above sample WSO2 API Manager running with default offset (0) and WSO2 ESB running with offset 3.
Note: If you want to use the anti-pattern of doing both Facade and mediation in the same layer, you can copy the ESB configuration to API Gateway configuration and get the same functional result.
Asanka Abeysinghe
Vice President of Solutions Architecture
Blog: https://asanka.abeysinghe.org






