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: Demonstrate the use of the Call mediator for non-blocking web service invocations. It also demonstrates how we can use the Call mediator to implement service chaining scenarios.

<definitions xmlns="http://ws.apache.org/ns/synapse">


    <proxy name="StockQuoteProxy"
           transports="https http"
           startOnLoad="true"
           trace="disable">
        <target>
            <inSequence>
                <call>
                    <endpoint key="StockQuoteService"/>
                </call>
                <header name="Action" value="urn:getQuote"/>
                <payloadFactory>
                    <format>
                        <m0:getQuote xmlns:m0="http://services.samples">
                            <m0:request>
                                <m0:symbol>WSO2</m0:symbol>
                            </m0:request>
                        </m0:getQuote>
                    </format>
                    <args/>
                </payloadFactory>
                <call>
                    <endpoint key="StockQuoteService"/>
                </call>
                <respond/>
            </inSequence>
        </target>
    </proxy>


    <endpoint name="StockQuoteService">
        <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
    </endpoint>


</definitions>

Prerequisites:

  • Deploy the SimpleStockQuoteService in sample Axis2 server and start it on port 9000.
  • Start Synapse with the sample configuration 500 (wso2esb-samples -sn 500).

In this sample, Call mediator does a direct service invocation to the StockQuoteService using the client request. After getting the response, a new payload is constructed using the Payload Factory mediator, and we invoke the StockQuoteService using the Call mediator again. Then, using the Respond mediator, the message is sent back to the client.

Invoke the client as follows.

ant stockquote -Dtrpurl=http://localhost:8280/services/StockQuoteProxy

  • No labels