This documentation is for WSO2 Enterprise Integrator version 6.0.0 . View documentation for the latest release in the 6.x.x family and the latest release in the 7.x.x family.

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

Note that WSO2 EI is shipped with the following changes to what is mentioned in this documentation:

  • <PRODUCT_HOME>/repository/samples/ directory that includes all Integration profile samples is changed to <EI_HOME>/samples/service-bus/.
  • <PRODUCT_HOME>/repository/samples/resources/ directory that includes all artifacts related to the Integration profile samples is changed to <EI_HOME>/samples/service-bus/resources/.

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