Sample 255: Switching from File Transport (FTP) to the Mail Transport
<definitions xmlns="http://ws.apache.org/ns/synapse">
<proxy name="StockQuoteProxy" transports="vfs">
<target>
<inSequence>
<header name="Action" value="urn:getQuote"/>
</inSequence>
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
<outSequence>
<property action="set" name="OUT_ONLY" value="true"/>
<send>
<endpoint>
<address uri="mailto:user@host"/> <!--CHANGE-->
</endpoint>
</send>
</outSequence>
</target>
<publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/>
<parameter name="transport.vfs.FileURI">vfs:ftp://guest:guest@localhost/test?vfs.passive=true</parameter> <!--CHANGE-->
<parameter name="transport.vfs.ContentType">text/xml</parameter>
<parameter name="transport.vfs.FileNamePattern">.*\.xml</parameter>
<parameter name="transport.PollInterval">15</parameter>
</proxy>
</definitions>
Objective
In sample 254 we looked at how the VFS transport
can be used to read files from the local file system. VFS transport can also be
used to read files from FTP, SFTP and CIFS sites. This sample illustrates how to
read from a remote FTP site and send the content to a remote client as an e-mail.
Pre-requisites
ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/
Sat Nov 18 21:01:23 IST 2006 SimpleStockQuoteService :: Generating quote for : IBM
Standard :: Stock price = $95.26454380258552
-
This sample requires access to a FTP site and an e-mail account.
-
Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2
-
Enable the VFS transport listener for Synapse (refer VFS setup guide for
more details).
-
Enable the mail transport sender for Synapse
(refer Mail transport setup
guide for more details).
-
Create a new test directory in the FTP site.
-
Open the repository/conf/sample/synapse_sample_255.xml and edit the
transport.vfs.FileURI parameter to point to the test directory in the FTP
server. Also change the endpoint in the out sequence to point to your
e-mail account.
-
Start Synapse using the configuration numbered 255 (repository/conf/sample/synapse_sample_255.xml)
Unix/Linux: sh synapse.sh -sample 255
Windows: synapse.bat -sample 255
Executing the Client
Copy the test.xml file in the repository/conf/sample/resources/vfs directory to
the directory given in transport.vfs.FileURI above (i.e the test directory in
FTP server). This file contains a simple stock quote request in XML/SOAP format.
<?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 will pick up the file from the FTP site and send the content to
the stock quote service in Axis2 over HTTP. Response from Axis2 will be sent to
the mail endpoint as an e-mail. It should show up in the configured e-mail account
after a few seconds.
Back to Catalog