Jeff
It seems like the Clone mediator does not copy transport level headers
of the original message to the clones. I am not sure if this was the
intended behavior or a bug, but Ruwan should be able to comment on it.
A quick work around would be to copy the $trp:FILE_NAME value to a local
message context before the clone. AFAIK local message context properties
are copied to clones
asankha
Jeff Davis wrote:
Sorry to belabor this thing, but I have one follow-up question. When I try
to reference the expression $trp:FILE_NAME from within my clone block, it
fails, as it evaluates to null. Yet, within the xslt that follows below the
clone node, it evaluates just fine. As with my previous example for this
thread, I am using vfs transport for the proxy service upon which the
validate shown below exists.
<validate source="//*[local-name()='csv']">
<schema key="schemas/CSVOrder.xsd"/>
<on-fail>
<clone continueParent="true">
<target >
<endpoint>
<address format="soap12" uri="
http://localhost:8280/soap/EsperService"/>
</endpoint>
<sequence>
<xslt key="xslt-key-esper-csv-err"
source="//*[local-name()='csv']">
<!-- failure occurs where, as $trp:FILE_NAME is null -->
<property name="filename"
expression="$trp:FILE_NAME"/>
<property name="errorType" value="XML Validation
Error"/>
</xslt>
</sequence>
</target>
</clone>
<property name="Subject" value="Errors occurs when processing order"
scope="transport"/>
<xslt key="xslt-key-email" source="//*[local-name()='csv']">
<!-- works fine here -->
<property name="filename" expression="$trp:FILE_NAME"/>
</xslt>
<send>
<endpoint>
<address uri="mailto:[EMAIL PROTECTED]" format="pox"/>
</endpoint>
</send>
<drop/>
</on-fail>
</validate>
Thanks!
On Wed, Aug 13, 2008 at 10:02 PM, Asankha C. Perera <[EMAIL PROTECTED]>wrote:
Hi Jeff
It looks as though the properties you provided as examples:
<property name="file path" expression="$trp:FILE_PATH"/>
<property name="file name" expression="$trp:FILE_NAME"/>
That the constant values provided in the expression were derived from
those
in
org.apache.synapse.transport.vfs.VFSConstants?
If that's the case, it maybe worth pointing that out in the Configuration
Language guide (or if I can be granted permission, I can add that note, or
I
can just create Jira).
Yes, we need to update the configuration language document.. you can get
its source from the SVN, and make the changes locally and create then patch
as "svn diff > yourchanges.patch" - you should use a plain text editor when
editing that HTML (and not a rich WYSIWYG editor) to keep your changes
clearly visible on the diff, and to prevent formatting and unwanted changes
by advanced editors, that sometimes breaks stuff :D
Then, please attach the patch to a JIRA and we will be very happy to
include your contribution
asankha
On Tue, Aug 12, 2008 at 2:59 AM, Asankha C. Perera <[EMAIL PROTECTED]>
wrote:
Hi Jeff
I'm trying to setup an inSequence node that, when validation fails, an
email
is sent out. The inbound message is arriving via transport.vfs. I'd like
the
content of my email to include the name of the inbound file. My on-fail
looks like:
<on-fail>
<property name="Subject" value="Errors occurs when processing order"
scope="transport"/>
<xslt key="xslt-key-email" source="//*[local-name()='csv']">
<property name="filename"
expression="get-property('transport.vfs.FileName')" scope="transport"/>
</xslt>
<send>
<endpoint>
<address uri="mailto:[EMAIL PROTECTED]" format="pox"/>
</endpoint>
</send>
<drop/>
</on-fail>
The filename parameter being passed to the xstl fails because the
property
isn't found. I've even tried instead to get one of the previously
defined
properties, such as "transport.vfs.FileURI", but that doesn't work
either.
The transport.vfs.FileURI is the URI of the file being polled.. this
could
be a directory as well, or a file etc.
To be honest, this is a fairly constant frustration for me -- I never
seem
to be able to printout property values successfully where log level is
custom either. It seems as though when you specify log level="full", it
would print out ALL the property valus, but that often doesn't appear to
be
the case (it just seems to print out only message context, not the
transport-specific ones).
Sorry for the delay as I was traveling last week..
But try this config:
<definitions xmlns="http://ws.apache.org/ns/synapse">
<proxy name="StockQuoteProxy" transports="vfs">
<parameter name="transport.vfs.FileURI">file:///tmp/in</parameter>
<!--CHANGE-->
<parameter name="transport.vfs.ContentType">text/plain</parameter>
<parameter name="transport.vfs.FileNamePattern">.*\.txt</parameter>
<parameter name="transport.PollInterval">15</parameter>
<parameter
name="transport.vfs.MoveAfterProcess">file:///tmp/original</parameter>
<!--CHANGE-->
<parameter
name="transport.vfs.MoveAfterFailure">file:///tmp/original</parameter>
<!--CHANGE-->
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<target>
<inSequence>
<log level="full">
<property name="file path" expression="$trp:FILE_PATH"/>
<property name="file name" expression="$trp:FILE_NAME"/>
<property name="file size"
expression="$trp:FILE_LENGTH"/>
<property name="last modified"
expression="$trp:LAST_MODIFIED"/>
</log>
</inSequence>
</target>
</proxy>
</definitions>
Note: you could also use the get-property('FILE_PATH') function as usual
at
transport scope instead of the cooler $trp:FILE_PATH etc
and you will see the following log message:
2008-08-12 14:25:47,383 [-] [vfs-Worker-1] INFO LogMediator To: ,
MessageID: urn:uuid:C9CD4AB9611C879A8B1218531347310, Direction: request,
file path = /tmp/in/hello.txt, file name = hello.txt, file size = 29,
last
modified = 1218531282000, Envelope: <?xml version='1.0'
encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="
http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><axis2ns1:text
xmlns:axis2ns1="http://ws.apache.org/commons/ns/payload">some text here
som more text</axis2ns1:text></soapenv:Body></soapenv:Envelope>
So basically the problem was not a bug, but the name of the property you
were looking at.. If you can help us improve our documentation that would
be
most welcome :)
asankha
--
Asankha C. Perera
WSO2 - http://wso2.org
http://esbmagic.blogspot.com
--
Asankha C. Perera
WSO2 - http://wso2.org
http://esbmagic.blogspot.com
--
Asankha C. Perera
WSO2 - http://wso2.org
http://esbmagic.blogspot.com