문제

I have a REST service that I want to use through wso2 ESB. The service returns a JSON object. I wish however to modify the JSON before it enters the ESB and gets processed.

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

My service configuration looks like this at the moment:

<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 some other way to modify the message body before it enters the ESB?

도움이 되었습니까?

해결책

at the synapse mediation engine level you can not access the json message. At the JSON builder level it converts the json message to an xml message. So you need to access the xml element and do your modifications there.

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

you can get the xml element as given above.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top