This documentation is for WSO2 Enterprise Service Bus version 4.9.0 . View documentation for the latest release.
||
Skip to end of metadata
Go to start of metadata

Introduction

This sample demonstrates how to use the VFS transport to access a windows share.

Prerequisites

  • Create a directory named test on a windows machine and create three sub directories named in, out and original within the test directory.
  • Grant permission to the network users to read from and write to the test directory and sub directories.
  • Open the ESB_HOME/repository/samples/synapse_sample_265.xml file in a text editor and change the transport.vfs.FileURI, transport.vfs.MoveAfterProcess, transport.vfs.MoveAfterFailure parameter values to the in, original and original directory locations respectively. You have to also change the <outSequence> endpoint address uri to the out directory location. Make sure that the prefix vfs: in the endpoint address uri is not removed or changed.
  • Enable the VFS transport. For details, see Enable VFS.
  • For a list of general prerequisites, see Prerequisites to Start the ESB Samples.

Building the sample

The XML configuration for this sample is as follows: 

<!-- Using the vfs transport to access a windows share -->
<definitions xmlns="http://ws.apache.org/ns/synapse">
    <proxy name="StockQuoteProxy" transports="vfs">
		<parameter name="transport.vfs.FileURI">smb://host/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">smb://host/test/original</parameter> <!--CHANGE-->
		<parameter name="transport.vfs.MoveAfterFailure">smb://host/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:smb://host/test/out"/> <!--CHANGE-->
                    </endpoint>
                </send>
            </outSequence>
        </target>
        <publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/>
    </proxy>
</definitions>

This configuration file  synapse_sample_265.xml is available in the <ESB_HOME>/repository/samples directory and the values you have to change as specified in the prerequisites section are marked with <!--CHANGE-->.

To build the sample

  1. Start the ESB with the sample 265 configuration. For instructions on starting a sample ESB configuration, see Starting the ESB with a sample configuration.
    The operation log keeps running until the server starts, which usually takes several seconds. Wait until the server has fully booted up and displays a message similar to "WSO2 Carbon started in n seconds."

  2. Start the Axis2 server. For instructions on starting the Axis2 server, see Starting the Axis2 server.

  3. Deploy the back-end service SimpleStockQuoteService. For instructions on deploying sample back-end services, see Deploying sample back-end services.

Executing the sample

The sample client used here is the Stock Quote Client, which can operate in several modes. For further details on this sample client and its operation modes, see Stock Quote Client.

To execute the sample client

Move the test.xml file from the <ESB_HOME>/repository/samples/resources/vfs directory to the location specified in transport.vfs.FileURI in the configuration (i.e., the in directory).

The  test.xml file contains a simple stock quote request in XML/SOAP format and is as follows:

test.xml
<?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>

Analyzing the output

You will see that the VFS transport listener picks the file from the in directory and sends it to the Axis2 service over HTTP. Then you will see that the request XML file is moved to the original directory and that the response from the Axis2 server is saved to the out directory.

  • No labels