Custom pick apache synapse

I have a REST service that I want to use through wso2 ESB. The service returns a JSON object. However, I want to change the JSON before it enters the ESB and is being processed.

I managed to deploy a custom class mediator, but I don’t know how I can process the message body with it (JSON object). Is this the right way to do this?

My service configuration looks like this:

<proxy xmlns="http://ws.apache.org/ns/synapse" name="ListRm" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target> <outSequence> <class name="org.mediator.MyMediator" /> <send /> <drop /> </outSequence> <endpoint> <address uri="http://xx.xx.xxx.xx:8080/alfresco/s/slingshot/datalists/lists/site/rm/documentLibrary" /> </endpoint> </target> </proxy> 

Also, is there any other way to change the message body before it enters the ESB?

+4
source share
1 answer

at the synapse mediation mechanism level, you cannot access the json message. At the JSON builder level, it converts a json message to an xml message. Therefore, you need to access the xml element and make your modifications to it.

messageContext.getEnvelope () getBody () getFirstElement (); ..

you can get the xml element as above.

+2
source

All Articles