Cloud Blog

The Power of Mediators: API Call Transformation and Orchestration

Sometimes you are lucky and the backend web services match exactly your desired public API design. But what if they do not? What if you need to change formats on the fly? Or do XSLT transformation? Or orchestrate multiple backend services called and joined into a single API?

Fear not! WSO2 API Cloud comes with a powerful mediation engine that can transform and orchestrate API calls on the fly.

You can create your mediation sequences and apply them on the fly both on the way to the backend (In Flow) and back to the invoker (Out Flow):

API Cloud mediation sequences

API Cloud’s mediation engine is built on industry-fastest enterprise service bus (ESB) engine and supports amazing variety of mediators that you can use as building blocks for your sequences: https://docs.wso2.com/display/ESB490/Mediators

WSO2 Developer Studio can then be used to build your sequences:

Sample mediator sequence

And then you simply upload the sequences to the gateway and select which of them you want used in your APIs.

There are a couple tutorials that we published to illustrate the process:

Using Property Mediator to turn YQL-based Yahoo Weather API into nice REST format:

This is the step-by-step tutorial if you want to follow along: https://docs.wso2.com/display/APICloud/Change+the+Default+Mediation+Flow+of+API+Requests

And here is another one on turning a SOAP backend into a proper JSON REST frontend API.

Here’s the full list of mediators supported and links to detailed documentation:

Category

Name

Description

Core Call Invoke a service in non blocking synchronous manner

Sequence

Inserts a reference to a sequence

Drop

Drops a message

Enrich

Enriches a message

Property

Sets or remove properties associated with the message

Log

Logs a message

Filter

Filter

Filters a message using XPath, if-else kind of logic

Validate Validates XML messages against a specified schema.

Switch

Filters messages using XPath, switch logic

Conditional Router

Implements complex routing rules (Header based routing, content based routing and other rules)

Transform

XSLT

Performs XSLT transformations on the XML payload

FastXSLT Performs XSLT transformations on the message stream

URLRewrite

Modifies and rewrites URLs or URL fragments

XQuery Performs XQuery transformation

Header

Sets or removes SOAP headers

Fault (also called Makefault)

Create SOAP Faults

PayloadFactory Transforms or replaces message content in between the client and the backend server

Advanced

Cache

Evaluates messages based on whether the same message came to the ESB

ForEach Splits a message into a number of different messages by finding matching elements in an XPath expression of the original message.

Clone

Clones a message

Iterate

Splits a message

Aggregate

Combines a message

Callout

Blocks web services calls

Transaction

Executes a set of mediators transactionally

DBReport

Writes data to database

DBLookup

Retrieves information from database

Entitlement

Evaluates user actions against a XACML policy

Extension

Class

Creates and executes a custom mediator

Script

Executes a mediator written in Scripting language

Start your free API Cloud trial now!

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories

Recent Posts

Most Popular Posts

Twitter Facebook LinkedIn