| <?xml version="1.0" encoding="ISO-8859-1" ?> |
| <!-- |
| ~ Licensed to the Apache Software Foundation (ASF) under one |
| ~ or more contributor license agreements. See the NOTICE file |
| ~ distributed with this work for additional information |
| ~ regarding copyright ownership. The ASF licenses this file |
| ~ to you under the Apache License, Version 2.0 (the |
| ~ "License"); you may not use this file except in compliance |
| ~ with the License. You may obtain a copy of the License at |
| ~ |
| ~ http://www.apache.org/licenses/LICENSE-2.0 |
| ~ |
| ~ Unless required by applicable law or agreed to in writing, |
| ~ software distributed under the License is distributed on an |
| ~ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| ~ KIND, either express or implied. See the License for the |
| ~ specific language governing permissions and limitations |
| ~ under the License. |
| --> |
| |
| <document> |
| <properties> |
| <title>Apache Synapse - Sample 254</title> |
| </properties> |
| <body> |
| <section name="Sample 254: Using File System as the Transport Medium (Reading/Writing Files)"> |
| <div class="xmlConf"><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/conf/sample/resources/proxy/sample_proxy_1.wsdl"/> |
| </proxy> |
| |
| </definitions></div> |
| <subsection name="Objective"> |
| <p> |
| Synapse can access the local file system using its VFS (Virtual File System) |
| transport receiver and sender. This way Synapse can read files in the local file |
| system as well as write to the local file system. This sample show cases the |
| Synapse VFS transport in action. |
| </p> |
| </subsection> |
| <subsection name="Pre-requisites"> |
| <p> |
| <ul> |
| <li> |
| Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2 |
| </li> |
| <li> |
| Create 3 new directories (folders) named 'in', 'out' and 'original' in a |
| suitable location in the local file system (eg: /home/user/test). |
| </li> |
| <li> |
| Open the repository/conf/sample/synapse_sample_254.xml file in a text |
| editor and. Then change the transport.vfs.FileURI, transport.vfs.MoveAfterProcess, |
| transport.vfs.MoveAfterFailure parameter values to the above in, original |
| and original directories respectively. Note that both 2nd and 3rd parameters |
| are pointed to the 'original' directory. |
| </li> |
| <li> |
| Change the endpoint in the out-sequence to point to the 'out' directory. |
| The prefix 'vfs' in the endpoint URL must not be removed or changed. |
| </li> |
| <li> |
| Enable the VFS transport receiver and sender for Synapse (refer VFS |
| setup guide for more information) |
| </li> |
| <li> |
| Start Synapse using the configuration numbered 254 (repository/conf/sample/synapse_sample_254.xml) |
| <div class="command"> |
| Unix/Linux: sh synapse.sh -sample 254<br/> |
| Windows: synapse.bat -sample 254 |
| </div> |
| </li> |
| </ul> |
| </p> |
| </subsection> |
| <subsection name="Executing the Client"> |
| <p> |
| 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 'in' directory). This |
| file contains a simple stock quote request in XML/SOAP format. |
| </p> |
| <div class="consoleOutput"><?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></div> |
| <p> |
| VFS transport listener will pick the file from 'in' directory and send it to the |
| Axis2 service over HTTP. The request XML file will be backed up in the 'original' |
| directory. The response from the Axis2 server will be saved to the 'out' directory. |
| </p> |
| </subsection> |
| </section> |
| <p><a href="../samples.html">Back to Catalog</a></p> |
| </body> |
| </document> |