|Table of Contents|
This sample demonstrates how a message can be passed through the WSO2 ESB and logged before it is delivered to its receiver. This is a basic, introductory usecase of WSO2 ESB. In this sample, we will deploy a sample client and a sample back-end service and transfer a message to the back-end service from the client through the WSO2 ESB.
For a list of prerequisites, see the Prerequisites section in ESB Samples Setup.
Building the Sample
1. Start the ESB with sample 0 configuration using the instructions given in Starting Sample ESB Configurations.
2. A message should appear in the command or text Linux console stating the server started successfully.
3. The synapse configuration in the ESB used for message mediation in this sample is provided in
synapse_sample_0.xml as shown below:
<definitions xmlns="http://ws.apache.org/ns/synapse"> <sequence name="main"> <in> <!-- log all attributes of messages passing through --> <log level="full"/> <!-- Send the message to implicit destination --> <send/> </in> <out> <!-- log all attributes of messages passing through --> <log level="full"/> <!-- send the message back to the client --> <send/> </out> </sequence> </definitions>
4. Deploy the back-end service 'SimpleStockQuoteService' and start the Axis2 server using the instructions given in section Starting Sample Back-End Services.
5. Now you have a running ESB instance and a back-end service deployed. In the next section, we will send a message to the back-end service through the ESB using a sample client.
Executing the Sample
1. The sample client used here is 'Stock Quote Client' which can operate in several modes. For instructions on this sample client and its operation modes, refer to Stock Quote Client. Run each of the following ant command from
<ESB_HOME>/samples/axis2Client directory to trigger a sample message to the back-end service. If the message is mediated successfully, it should display an output on the Axis2 server's start-up console.
Smart Client Mode
ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/
Using ESB as a HTTP Proxy
ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dprxurl=http://localhost:8280/
Gateway Mode / Dumb Client
Execute the Smart Client
By tracing the execution of ESB with the log output level set to DEBUG, you will see the client request arriving at ESB with a WS-Addressing
To set to EPR .The ESB engine logs the message at the "full" log level (all the message headers and the body) then sends the message to its implicit
To address which is .You will see a message in the Axis2 server console confirming that the message got routed to the sample server and the sample service hosted at the sample server generating a stock quote for the requested symbol.
Sat Nov 18 21:01:23 IST 2006 SimpleStockQuoteService :: Generating quote for : IBM
The response message generated by the service is again received by ESB, and flows through the same mediation rules, which logs the response message and then sends it back to the client. On the client console you should see an output similar to the following based on the message received by the client.
Standard :: Stock price = $95.26454380258552
Execute the Proxy Client
You will see exactly the same behavior as per the previous example when you run this scenario. However, this time the difference is at the client, as it sends the message to the WS-Addressing
To address , but the transport specifies ESB as the HTTP Proxy.
Example of message mediation in WSO2 ESB.