Sample 654: Smooks Mediator
Objective:Demonstrate the smooks mediatot EDI message processing.
Here is the sample with smooks mediator.
<definitions xmlns="http://ws.apache.org/ns/synapse"> <localEntry key="transform-xslt-key" src="file:repository/samples/resources/smooks/transform.xslt"/> <localEntry key="smooks-key" src="file:repository/samples/resources/smooks/smooks-config.xml"/> <proxy name="StockQuoteProxy" transports="vfs"> <parameter name="transport.vfs.ContentType">text/plain</parameter> <!--CHANGE--> <parameter name="transport.vfs.ContentType">text/plain</parameter> <parameter name="transport.vfs.FileURI">file:///home/user/dev/test/smooks/in</parameter> <parameter name="transport.vfs.FileNamePattern">.*\.txt</parameter> <parameter name="transport.PollInterval">5</parameter> <!--CHANGE--> <parameter name="transport.vfs.MoveAfterProcess">file:///home/user/dev/test/smooks/original</parameter> <!--CHANGE--> <parameter name="transport.vfs.MoveAfterFailure">file:///home/user/dev/test/smooks/original</parameter> <parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter> <parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter> <parameter name="Operation">urn:placeOrder</parameter> <target> <inSequence> <smooks config-key="smooks-key"/> <xslt key="transform-xslt-key"/> <iterate expression="//m0:placeOrder/m0:order" preservePayload="true" attachPath="//m0:placeOrder" xmlns:m0="http://services.samples"> <target> <sequence> <header name="Action" value="urn:placeOrder"/> <property action="set" name="OUT_ONLY" value="true"/> <send> <endpoint> <address format="soap11" uri="http://localhost:9000/services/SimpleStockQuoteService"/> </endpoint> </send> </sequence> </target> </iterate> </inSequence> <outSequence/> </target> <publishWSDL uri="file:repository/samples/resources/smooks/PlaceStockOrder.wsdl"/> </proxy> </definitions>
1. Deploy the SimpleStockQuoteService in sample Axis2 server and start it on port 9000. Then add the plain text builder to the messageBuilders section of the axis2.xml found in the repository/conf directory. Here is the sample configuration.
<messageBuilder contentType="text/plain" class="org.apache.axis2.format.PlainTextBuilder"/>
2. Enable the vfs transport in axis2.xml by uncomenting the vfs transport sender and receiver configurations in the axis2.xml.
3. User has to edit the synapse_sample_654.xml found in the repository/samples directory. These are the configuration parameters that needs to be edited.
- transport.vfs.FileURI
- transport.vfs.MoveAfterProcess
- transport.vfs.ActionAfterFailure
4. Start ESB with the sample configuration 654 (i.e. wso2esb-samples.sh -sn 654).
5. Drop the edi.txt file found in the repository/samples/resources/smooks directory to the transport.vfs.FileURI parameter specified directory.