Search code examples
wso2file-writingwso2-esb

writing into file using VFS -WSO2 ESB 4.8.1


This sequence is for writing one specific field value into the file.Problem is we only need content,but using xml label is coming and if I use json then value comes into {}`

                             {$1}

                       </format>
                       <args>
                          <arg evaluator="xml" expression="//FieldValue"/>
                       </args>
                    </payloadFactory>
                    <property name="OUT_ONLY" value="true"/>
                    <send>
                       <endpoint name="FileEpr">`target path`
                          <address uri="vfs:file://D:/Documents/File/out"/>
                       </endpoint>
                    </send>
                 </Sequence>    

1.My question is is there any way to write content only?? 2.In this code I used payload factory,is there any way to write into a file using some other mediator?? Please suggest how yo write into a file without using payload factory


Solution

  • You can use whatever method to apply your transformation : payloadFactory, javascript, XSL, custom class, ...

    If what you call "content only" is a way to produce a text file, you must generate (with your transformation) a xml message with a soap body like this :

    <text xmlns="http://ws.apache.org/commons/ns/payload">your text payload</text>
    

    Sample with payloadFactory :

                <payloadFactory>
                   <format>
                     <ns:text xmlns:ns="http://ws.apache.org/commons/ns/payload">$1</ns:text>
                   </format>
                   <args>
                      <arg evaluator="xml" expression="//FieldValue/text()"/>
                   </args>
                </payloadFactory>
    

    Before send mediator, think to specify message format so that WSO2 ESB can choose the right message formatter :

    <property name="messageType" value="text/plain; charset=windows-1252" scope="axis2"/>