Reputation: 393
i am getting a data or string from front end i am setting the data or string in one property that property data i need to send in text file every time they will send the data i need keep the data in same file without override how can i do i have done using VFS transport i uncommented sender section of vfs in configuration file even though its not working fine below configuration
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="FileWrite"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<property name="error" expression="//error/text()" scope="default"/>
<log level="full"/>
</inSequence>
<outSequence>
<log>
<property name="error" expression="get-property('error')" scope="default"/>
<property name="OUT_ONLY" value="true"/>
</log>
<payloadFactory>
<format>
<error>$1</error>
</format>
<args>
<arg expression="get-property('error')"/>
</args>
</payloadFactory>
<log level="full"/>
<send>
<endpoint>
<address uri="vfs:file:///home/youtility2/Desktop/Errorlog.text"/>
</endpoint>
</send>
<log level="full"/>
</outSequence>
</target>
<parameter name="transport.vfs.Append">true</parameter>
</proxy>
i created text file on desktop but data is not writing in text file and also not giving any exception also will refer something for this
Upvotes: 1
Views: 3719
Reputation: 447
you can also try class mediator in wso2esb.In java class Using FileWriter it is possible to write into text file like this:
FileWriter(File file, boolean append)
or
FileWriter(String fileName, boolean append)
Upvotes: 0
Reputation: 3400
Below code shows the capability to insert payload into a file. You don't need to use vfs as transport.
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="WriteIntoFile"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<property name="transport.vfs.ReplyFileName"
expression="fileName.xml')"
scope="transport"/>
<send>
<endpoint>
<address uri="vfs:ftp://admin:admin@localhost:21/srcFolder?vfs.passive=true"/>
</endpoint>
</send>
</inSequence>
</target>
</proxy>
Upvotes: 1
Reputation: 2295
You have to enable VFS Transport for the Proxy service. In proxy creation/edit wizard you can select necessary transports. Once you have enabled VFS transport in axis2.xml, VFS will apear as an available transport for services. So if it is to use in a proxy service it should be enabled to that particular service as well.
So in your proxy element, transport attribute will be transports="https http vfs"
In order to append to the same file, define the transport.vfs.Append parameter with the file URI as described in the doc[2]
[2]http://docs.wso2.org/wiki/display/ESB450/VFS+Transport
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="FileWrite"
transports="https http vfs"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<property name="OUT_ONLY" value="true"/>
<property name="error" expression="//error/text()" scope="default"/>
<log level="full"/>
</inSequence>
<outSequence>
<log>
<property name="error" expression="get-property('error')" scope="default"/>
<property name="OUT_ONLY" value="true"/>
</log>
<payloadFactory>
<format>
<error>$1</error>
</format>
<args>
<arg expression="get-property('error')"/>
</args>
</payloadFactory>
<log level="full"/>
<send>
<endpoint>
<address uri="vfs:file:///home/youtility2/Desktop/Errorlog.text?transport.vfs.Append=true"/>
</endpoint>
</send>
<log level="full"/>
</outSequence>
</target>
<parameter name="transport.vfs.Append">true</parameter>
</proxy>
Upvotes: 2
Reputation: 1232
it should be as In URL
vfs:file:///home/user/test/out? transport.vfs.Append=true "
as Parameter
<parameter name="transport.vfs.ReplyFileURI">file:///home/user/test/out? transport.vfs.Append=true </parameter>
For vfs service level parameters you can refer [1].
I just roughly edit your proxy try with this.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="FileWrite"
transports="vfs" statistics="disable" trace="disable" startOnLoad="true">
<description/>
<target>
<inSequence>
<property name="error" expression="//error/text()" scope="default"/>
<log level="full"/>
</inSequence>
<outSequence>
<log>
<property name="error" expression="get-property('error')" scope="default"/>
<property name="OUT_ONLY" value="true"/>
</log>
<payloadFactory>
<format>
<error>$1</error>
</format>
<args>
<arg expression="get-property('error')"/>
</args>
</payloadFactory>
<log level="full"/>
<send>
<endpoint>
<address uri="vfs:file:///home/youtility2/Desktop/Errorlog? transport.vfs.Append=true"/>
</endpoint>
</send>
<log level="full"/>
</outSequence>
</target>
<parameter name="transport.PollInterval">10</parameter>
<parameter name="transport.vfs.FileURI">file:///home/youtility2/Desktop/Errorlog.text</parameter>
<parameter name="transport.vfs.FileNamePattern">.*.xml</parameter>
<parameter name="transport.vfs.ContentType">text/xml</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
</proxy>
[1].http://docs.wso2.org/wiki/display/ESB460/VFS+Transport
Upvotes: 0