Sample 0: Introduction to Synapse

<definitions xmlns=""> <sequence name="main"> <!-- log all attributes of messages passing through --> <log level="full"/> <!-- Send the message to implicit destination --> <send/> <sequence/> </definitions>


Introduction to Synapse - Shows how Synape can be configured to log and pass messages through.


  • Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2
  • Start Synapse using the configuration numbered 0 (repository/conf/sample/synapse_sample_0.xml)
    Unix/Linux: sh -sample 0
    Windows: synapse.bat -sample 0

Executing the Client

Smart Client Mode

Execute the client in the smart client mode using the following command.

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

By tracing the execution of Synapse with the log output level set to DEBUG, you will see that the client request is arriving at Synapse with a WS-Addressing 'To' header set to EPR http://localhost:9000/services/SimpleStockQuoteService. The Synapse engine logs the message at the 'full' log level (i.e. all the message headers and the body) and then sends it to its explicit 'To' address which is http://localhost:9000/services/SimpleStockQuoteService. You will see a log entry in the Axis2 server console confirming that the message got routed to the sample server and the service hosted at the server generated 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 received by Synapse, and flows through the same mediation rules, which log the response and send 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

Proxy Client Mode

Execute the sample Axis2 client as follows to run it in the proxy mode.

ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dprxurl=http://localhost:8280/

You will see the exact same behaviour as per the previous example when you run this scenario. However this time the client sends the message to the Axis2 server using Synapse as a HTTP proxy.

The Axis2 client supports another mode of operation known as the 'dumb client mode'. This will be addressed in sample 1.

Back to Catalog