You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by byoung4877 <by...@gmail.com> on 2012/03/07 22:48:20 UTC
Processor to xpath
Hi, Please Help!! I'm pretty new to camel so bear that in mind. I'm trying to
inject a header in to a message from a Processor I've implemented. However,
when I run I keep getting this:
[Fatal Error] :1:1: Content is not allowed in prolog."
Below is my camel context:
<bean id="billingRequestProcessor"
class="com.foobar.BillingRequestProcessor"/>
<camelContext id="camelContext"
xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="file:C:\FTP\BILLING_REQUEST_PENDING?delete=true"/>
<process ref="billingRequestProcessor"/>
<choice>
<when>
<xpath>$fileAccepted = 'true'</xpath>
<to uri="file:C:\FTP\BILLING_REQUEST"/>
</when>
<otherwise>
<to uri="file:C:\FTP\BILLING_REQUEST_ERROR"/>
</otherwise>
</choice>
</route>
</camelContext>
And in BillingRequestProcessor I am doing some processing resulting in:
@Override
public void process(Exchange exchange) throws Exception {
Map<String, Object> headers = exchange.getIn().getHeaders();
headers.put("fileAccepted", "true");
exchange.getIn().setHeaders(headers);
}
--
View this message in context: http://camel.465427.n5.nabble.com/Processor-to-xpath-tp5545719p5545719.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Processor to xpath
Posted by byoung4877 <by...@gmail.com>.
Fantastic! That worked. I'm using a .dat flat file. I was assuming I could
still use xpath for non-xml messages. Thanks a bunch!!
--
View this message in context: http://camel.465427.n5.nabble.com/Processor-to-xpath-tp5545719p5547818.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Processor to xpath
Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Mar 7, 2012 at 10:48 PM, byoung4877 <by...@gmail.com> wrote:
> Hi, Please Help!! I'm pretty new to camel so bear that in mind. I'm trying to
> inject a header in to a message from a Processor I've implemented. However,
> when I run I keep getting this:
>
> [Fatal Error] :1:1: Content is not allowed in prolog."
>
This kind of error is from the XML parser that says the message is not
valid XML. eg the message should have that XML header in the top, with
<?xml version="1.0">
So when the message is evaluated as an XML using the xpath expression
it will fail.
Are you sure its an XML message?
Instead of <xpath> you can use <simple> to evaluate a header
<simple>${header.fileAccepted} == true</simple>
> Below is my camel context:
>
> <bean id="billingRequestProcessor"
> class="com.foobar.BillingRequestProcessor"/>
> <camelContext id="camelContext"
> xmlns="http://camel.apache.org/schema/spring">
> <route>
> <from uri="file:C:\FTP\BILLING_REQUEST_PENDING?delete=true"/>
> <process ref="billingRequestProcessor"/>
> <choice>
> <when>
> <xpath>$fileAccepted = 'true'</xpath>
> <to uri="file:C:\FTP\BILLING_REQUEST"/>
> </when>
> <otherwise>
> <to uri="file:C:\FTP\BILLING_REQUEST_ERROR"/>
> </otherwise>
> </choice>
> </route>
> </camelContext>
>
> And in BillingRequestProcessor I am doing some processing resulting in:
>
> @Override
> public void process(Exchange exchange) throws Exception {
> Map<String, Object> headers = exchange.getIn().getHeaders();
> headers.put("fileAccepted", "true");
> exchange.getIn().setHeaders(headers);
> }
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Processor-to-xpath-tp5545719p5545719.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/