Question

I want to read some values from a file that being processed by the VFS transport.
My file is :

<sales>
<header>
    <source>STORE1</source>
    <target>HEADOFFICE</target>
</header>

So I use a property mediator to get the value I want using XPath. But when I print that property in Log Mediator it prints nothing. My proxy look like this :

   <proxy name="Try1"
      transports="vfs"
      startOnLoad="true"
      trace="disable">
  <target>
     <inSequence>
        <property xmlns:ns="http://org.apache.synapse/xsd"
                  name="source"
                  expression="//header/source/text()"
                  scope="default"
                  type="STRING"/>
        <log level="full">
           <property xmlns:ns="http://org.apache.synapse/xsd"
                     name="Value_source"
                     expression="get-property('source')"/>
        </log>
     </inSequence>
  </target>
  <parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
  <parameter name="transport.PollInterval">15</parameter>
  <parameter name="transport.vfs.MoveAfterProcess">file:///Users/Target</parameter>
  <parameter name="transport.vfs.FileURI">file:///Users/Source</parameter>
  <parameter name="transport.vfs.MoveAfterFailure">file:///Users/Failure</parameter>
  <parameter name="transport.vfs.FileNamePattern">.*.txt</parameter>
  <parameter name="transport.vfs.ContentType">text/plain</parameter>
  <parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>

The log mediator result is

[2013-06-28 16:59:49,939]  INFO - LogMediator Value_source=

So how can I get the values in file using XPath?

Was it helpful?

Solution

The issue is due to the ContentType set for the transport parameter:

Switch

<parameter name="transport.vfs.ContentType">text/plain</parameter>

with

<parameter name="transport.vfs.ContentType">application/xml</parameter>

since you're doing XPath operations on the message.

OTHER TIPS

The problem is with the content of your file. Since it is not well-formed, the xpath expression fails. Isn't it possible for you to have the well-formed xml in the input content?

<sales>
<header>
    <source>STORE1</source>
    <target>HEADOFFICE</target>
</header>
</sales> 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top