This documentation is for WSO2 Enterprise Service Bus version 5.0.0. For the latest ESB, view the latest WSO2 Enterprise Integrator documentation.

All docs This doc
Skip to end of metadata
Go to start of metadata

Objective: Introduction to inline script mediation


  • Start the Synapse configuration numbered 351: i.e. -sn 351
  • Start the Axis2 server and deploy the SimpleStockQuoteService if not already done.
<definitions xmlns="">
        <!-- transform the custom quote request into a standard quote request expected by the service -->
        <script language="js"><![CDATA[
               var symbol = mc.getPayloadXML()..*::Code.toString();
                  <m:getQuote xmlns:m="http://services.samples/xsd">
                <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
        <!-- transform the standard response back into the custom format the client expects -->
        <script language="js"><![CDATA[
               var symbol = mc.getPayloadXML()..*::symbol.toString();
               var price = mc.getPayloadXML()..*::last.toString();
                  <m:CheckPriceResponse xmlns:m="http://services.samples/xsd">

The functionality of this sample is similar to that of sample 350 and sample 8. It demonstrates how to use inline scripts in the mediation within the ESB. Use the stock quote client to issue a custom quote client as follows.


ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dmode=customquote
ESB uses the script mediator and the specified Javascript function to convert the custom request to a standard quote request. Subsequently the response received is transformed and sent back to the client.


  • No labels