Enterprise Integration Zone is brought to you in partnership with:

I am a graduate of University of Westminster UK (IIT) B Sc Software Engineering ( First Class Honours). I am a Sun Certified Java Programmer for Java 2 platform, 1.5 versions (SCJP 1.5). – 93% and a Sun Certified Web Component Developer 97%. I work as a Software Engineer at WSO2. Achala is a DZone MVB and is not an employee of DZone and has posted 20 posts at DZone. You can read more from them at their website. View Full User Profile

How to Write a Custom Mediator in WSO2 ESB

05.10.2013
| 1436 views |
  • submit to reddit

I will use WSO2 Developer Studio to write the custom mediator.

Click Developer studio tab and click open dashboard.








You can write the mediator logic in the following. 
Next create a carbon application project.

Next give the project name and select necessary dependencies.



Give a project name and click finish.

Next click "create archive"

Select the location (in file system) , Click 'OK'

Place the mediator (.car) to wso2esb-4.0.3/repository/deployment/server/carbonapps

The following code is a sample proxy service which will use a custom mediator
<proxy xmlns="http://ws.apache.org/ns/synapse" name="test" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <class name="org.wso2.carbon.sample.FirstMediator" />
         <log level="full" />
         <send>
            <endpoint>
               <address uri="http://localhost:8282/services/SimpleStockQuoteService/" />
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <send />
      </outSequence>
   </target>
</proxy>



Published at DZone with permission of Achala Chathuranga Aponso, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)