Child pages
  • Sample 254: Using the File System as Transport Medium (VFS)

This documentation is for WSO2 ESB version 4.5.1. View documentation for the latest release.

Skip to end of metadata
Go to start of metadata

Objective: Using the file system as transport medium using VFS transport listener and sender.

Prerequisites
  • Start the Axis2 server and deploy the SimpleStockQuoteService if not already done
  • Create three new directories in a test directory, for example, in, out, original in /home/user/test. Open ESB_HOME/repository/samples/synapse_sample_254.xml and edit the following values. Change transport.vfs.FileURI, transport.vfs.MoveAfterProcess, transport.vfs.MoveAfterFailure parameter values to the above in, original, original directories respectively. Change outSequence endpoint address URI to out directory with the prefix vfs:. Values you have to change are marked with <!--CHANGE-->.
  • Start the Synapse configuration numbered 254: wso2esb-samples.sh -sn 254
  • Copy ESB_HOME/repository/samples/resources/vfs/test.xml to the directory given in transport.vfs.FileURI above.
<definitions xmlns="http://ws.apache.org/ns/synapse">
	<proxy name="StockQuoteProxy" transports="vfs">
    	<parameter name="transport.vfs.FileURI">file:///home/user/test/in</parameter> <!--CHANGE-->
        <parameter name="transport.vfs.ContentType">text/xml</parameter>
        <parameter name="transport.vfs.FileNamePattern">.*\.xml</parameter>
        <parameter name="transport.PollInterval">15</parameter>
        <parameter name="transport.vfs.MoveAfterProcess">file:///home/user/test/original</parameter> <!--CHANGE-->
        <parameter name="transport.vfs.MoveAfterFailure">file:///home/user/test/original</parameter> <!--CHANGE-->
        <parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
        <parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
        <target>
        	<endpoint>
            	<address format="soap12" uri="http://localhost:9000/services/SimpleStockQuoteService"/>
            </endpoint>
            <outSequence>
            	<property name="transport.vfs.ReplyFileName"
                          expression="fn:concat(fn:substring-after(get-property('MessageID'), 'urn:uuid:'), '.xml')"
						  scope="transport"/>
                <property action="set" name="OUT_ONLY" value="true"/>
                <send>
                	<endpoint>
                    	<address uri="vfs:file:///home/user/test/out"/> <!--CHANGE-->
                    </endpoint>
                </send>
			</outSequence>
		</target>
        <publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/>
	</proxy>
</definitions>

test.xml file content is as follows:

<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
    <soapenv:Body>
    	<m0:getQuote xmlns:m0="http://services.samples">
        	<m0:request>
            	<m0:symbol>IBM</m0:symbol>
            </m0:request>
        </m0:getQuote>
    </soapenv:Body>
</soapenv:Envelope>

VFS transport listener will pick the file from in directory and send it to the Axis2 service. The request XML file will be moved to original directory. The response from the Axis2 server will be saved to out directory.

  • No labels