Sunday, May 16, 2021

WSO2 - ESB Create Mediator with JSON

 Create CustomMediator extend AbstractMediator 


import org.apache.synapse.commons.json.JsonUtil;

import org.apache.synapse.mediators.AbstractMediator;


public class CustomMediator extends AbstractMediator {

 public boolean mediate(MessageContext context) {

   //Read JSON from  Axis2 context

   String jsonAsString =  JsonUtil.jsonPayloadToString(((Axis2MessageContext) context)

                    .getAxis2MessageContext());

   ..........

    //Write JSON to  Axis2 context

    String convertedJsonPayloadObject =....;

    JsonUtil.newJsonPayload(((Axis2MessageContext) context).getAxis2MessageContext(),convertedJsonPayloadObject, true, true);

   return  true;

 }

}

No comments:

Post a Comment

Install and use xorg-server on macOS via Homebrew

  The instructions to install and use xorg-server on macOS via Homebrew: Install Homebrew (if you haven't already): /bin/bash -c ...