This documentation is for WSO2 Enterprise Service Bus version 4.7.0 . View documentation for the latest release.
Skip to end of metadata
Go to start of metadata

Objective: Introduce ESB Mediation Libraries and how to invoke the templates.

<proxy name="SampleLibProxy" transports="https http" startOnLoad="true" trace="disable">
    <target>
        <inSequence>
            <call-template target="org.apache.synapse.sample.stockquote"/>
            <drop/>
        </inSequence>
    </target>
</proxy>

Prerequisites

 

  1. You have to start the axis2 server and deploy the SimpleStockQuoteService.
  2. Start the Synapse configuration numbered 850: wso2esb-samples.sh -sn 850
  3. Click 'Add' under 'Mediation Libraries' section
  4. Download SampleConnectorLib library.
  5. Upload the above library to WSO2ESB.
  6. After upload is complete, click on 'List'. Import SampleConnectorLib.

In this example "SampleLibProxy" is created to invoke templates defined in the "SampleConnectorLib" library. Target name is a combination of the package name of the library and the target operation name. Package name of "SampleConnectorLib" is "org.apache.synapse.sample" and the operation defined inside is "stockquote".

Following is the template of the "stockquote" operation.

<template xmlns="http://ws.apache.org/ns/synapse" name="stockquote">
    <sequence>
        <in>
            <send>
                <endpoint>
                    <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
                </endpoint>
            </send>
        </in>
        <out>
            <send/>
        </out>
    </sequence>
</template>

To invoke the "SampleLibProxy" execute the stock quote client by requesting for a stock quote on the proxy service as follows:

ant stockquote -Daddurl=http://localhost:8280/services/SampleLibProxy

When the stockquote request is sent to the SampleLibProxy, it calls the stockquote template and then the request is forwarded to the sample service hosted on Axis2. The response from the SimpleStockQuoteService is sent back to the client. 

  • No labels