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

Objective: Simple message transformation - Rule mediator for message transformation.

<!-- Simple rule based transformation (changing message )  -->
<definitions xmlns="">

    <sequence name="main">

            <rule xmlns="">
                <target action="replace" xmlns:m0="http://services.samples" resultXpath="//m0:symbol"
                    <rule resourceType="regular" sourceType="inline">
                        <![CDATA[ package SimpleRoutingRules;

                        rule InvokeIBM
                        symbol: String()
                        eval( symbol.equals("MSFT") || symbol.equals("SUN") )
                <input namespace="http://services.samples" wrapperElementName="getQuote">
                    <fact xmlns:m0="http://services.samples" elementName="symbol" namespace="http://services.samples"
                          type="java.lang.String" xpath="//m0:getQuote/m0:request/m0:symbol/child::text()"/>
                <output namespace="http://services.samples" wrapperElementName="getQuote">
                    <fact elementName="symbol" namespace="http://services.samples" type="java.lang.String"/>
                    <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>




  • Start the Synapse configuration numbered 600: (i.e. ./ -sn 600)
  • Start the Axis2 server and deploy the SimpleStockQuoteService if not already deployed
  • In this sample , a simple transformation is happened . If the symbol is either SUN or MSFT , then it will changed into IBM in the SOAP envelope and then invoke the external service.

Run the client as

ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=MSFT

Or as

ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=SUN

Then check the axis2server log or console

Wed July 04 16:33:05 IST 2012 :: Generating quote for : IBM
  • No labels