Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/athiththan11/revamp-mediator

A custom mediation logic to convert payload attribute values using WSO2 Class Mediator extension
https://github.com/athiththan11/revamp-mediator

class-mediator extension mediator wso2 wso2-class-mediator

Last synced: about 1 month ago
JSON representation

A custom mediation logic to convert payload attribute values using WSO2 Class Mediator extension

Awesome Lists containing this project

README

        

# Revamp Mediator

A custom implementation to convert the attribute values of payloads using WSO2 Class Mediator extensions.

[Medium Story](https://medium.com/@athiththan11/wso2-class-mediators-convert-payloads-946a4fc5aa4a)

Simply put, the mediation logic will do the following conversion

```json
// original payload

{
"post": "WSO2 Class Mediator: Revamp",
"dev": {
"name": "medium"
}
}
```

to

```json
// converted

{
"post": "WSO2 Class Mediator: Revamp",
"dev": {
"name": "Athiththan"
}
}
```

## Build

Build the project by running ...

```shell
mvn clean package
```

## Deploy

After a successful build, copy the `revamp-mediator-1.0.0.jar` artifact from the `target` folder and paste it inside `/repository/components/lib` folder. And specify the deployed class mediator inside your required synapse configuration file.

For this demo, I will be using the WSO2 API Manager (2.6.0) and I will choose the `_TokenAPI_.xml` from the API Synapse Configuraitons folder (You can find your `API Synapse Configurtions` inside the `/repository/deployment/server/synapse-configs/default/api` folder), which will look as follows ...

```xml









60000
fault












```

Add our custom mediator inside the `inSequence` section, which will result in ...

```xml





```

## Run

Start your WSO2 API Manager server by executing the command from your `/bin` folder

```shell
sh wso2server.sh
```

or

```shell
wso2am-2.6.0
```

## Test & Results

Use the following cUrl command to invoke the `token` endpoint to examine the mediation logic

```cUrl
curl -k --header "Content-Type: application/json" --request POST --data '{"post":"WSO2 Class Mediator: Revamp","dev":{"name":"medium"}}' https:///token
```

After a successful execution, You will find the results as follows

```json
{"post":"WSO2 Class Mediator: Revamp","dev":{"name":"Athiththan"}}
```