Sample 655: Message Relay - Basics Sample
Objective: Demonstrate the Message Relay.
This sample is similar to sample 150 except we have added two log mediators to show the actual message going through the ESB.
<?xml version="1.0"?> <definitions xmlns="http://ws.apache.org/ns/synapse"> <proxy name="StockQuoteProxy" startOnLoad="true"> <target> <inSequence> <log level="full"/> <send> <endpoint name="epr"> <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> </endpoint> </send> </inSequence> <outSequence> <log level="full"/> <send/> </outSequence> </target> <publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/> </proxy> <sequence name="fault"> <log level="full"> <property name="MESSAGE" value="Executing default "fault" sequence"/> <property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/> <property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/> </log> <drop/> </sequence> <sequence name="main"> <log/> <drop/> </sequence> </definitions>
Prerequisites: Deploy the SimpleStockQuoteService in sample Axis2 server and start it on port 9000. Then uncomment the Message Relay's Message Builder and Message Formatter in the axis2.xml. These configurations can be found in the messageFormatters and messageBuilders section of the axis2.xml. A message formatter or builder is defined for a content type. So make sure you comment out the normla builders and formatters for a content type when uncomenting the message relay builders and formatters.
Here are the Message Relay Formatter and Builder classes. You need to uncomment the entries containing the following builder and formatter.
org.wso2.carbon.relay.ExpandingMessageFormatter org.wso2.carbon.relay.BinaryRelayBuilder
Send a message to the sample using the sample axis2 client.
ant stockquote -Daddurl=http://localhost:8280/services/StockQuoteProxy
You can see the messages going through the proxy by looking at the console because we have two log mediators in this sample. The actual message is not built and printed as a Base64 encoded string.