Sample 656: Message Relay - Builder Mediator
Objective:Demonstrate the Message Relay with Builder mediator.
This sample is similar to sample 655. We have added the builder mediator to build the actual message before logging it.
<definitions xmlns="http://ws.apache.org/ns/synapse"> <proxy name="StockQuoteProxy" startOnLoad="true"> <target> <inSequence> <builder> <messageBuilder contentType="application/xml" class="org.apache.axis2.builder.ApplicationXMLBuilder" formatterClass="org.apache.axis2.transport.http.ApplicationXMLFormatter"/> <messageBuilder contentType="application/xop+xml" class="org.apache.axis2.builder.MTOMBuilder"/> <messageBuilder contentType="multipart/related" class="org.apache.axis2.builder.MIMEBuilder"/> <messageBuilder contentType="application/x-www-form-urlencoded" class="org.apache.axis2.builder.XFormURLEncodedBuilder" formatterClass="org.apache.axis2.transport.http.XFormURLEncodedFormatter"/> <messageBuilder contentType="text/xml" class="org.apache.axis2.format.PlainTextBuilder" formatterClass="org.apache.axis2.format.PlainTextFormatter"/> <messageBuilder contentType="application/soap+xml" class="org.apache.axis2.builder.SOAPBuilder"/> </builder> <log level="full"/> <send> <endpoint name="epr"> <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> </endpoint> </send> </inSequence> <outSequence> <builder> <messageBuilder contentType="application/xml" class="org.apache.axis2.builder.ApplicationXMLBuilder" formatterClass="org.apache.axis2.transport.http.ApplicationXMLFormatter"/> <messageBuilder contentType="application/xop+xml" class="org.apache.axis2.builder.MTOMBuilder"/> <messageBuilder contentType="multipart/related" class="org.apache.axis2.builder.MIMEBuilder"/> <messageBuilder contentType="application/x-www-form-urlencoded" class="org.apache.axis2.builder.XFormURLEncodedBuilder" formatterClass="org.apache.axis2.transport.http.XFormURLEncodedFormatter"/> <messageBuilder contentType="text/xml" class="org.apache.axis2.format.PlainTextBuilder" formatterClass="org.apache.axis2.format.PlainTextFormatter"/> <messageBuilder contentType="application/soap+xml" class="org.apache.axis2.builder.SOAPBuilder"/> </builder> <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:Set up is same as sample 655.
ant stockquote -Daddurl=http://localhost:8280/services/StockQuoteProxy
You can see the actual messages going through the proxy by looking at the console because we have two log mediators in this sample. Becuase we have the builder mediator in place, unlike in sample 655 we have the actual message printed.