On Tue, Oct 13, 2009 at 6:54 PM, Dragisa Krsmanovic
<dkrsmano...@plos.org> wrote:
> On Tue, 2009-10-13 at 06:13 +0200, Claus Ibsen wrote:
>> On Mon, Oct 12, 2009 at 10:39 PM, Dragisa Krsmanovic
>> <dkrsmano...@plos.org> wrote:
>> > I am trying to do something like:
>> >
>> >  from("activemq:plos.pmc")
>> >    .to("rnc:pmc-message.rnc")
>> >    .setHeader(DOI).xpath("/ambraMessage/doi/text()", String.class)
>> >    
>> > .setHeader(Exchange.FILE_NAME).xpath("/ambraMessage/archive/text()",String.class)
>> >  ...
>> >
>> > But it doesn't allow me to add any setHeader methods
>> > after .to("rnc:...") I want to validate a message before I try to
>> > extract Xpath and I have an onException handler to catch
>> > ValidationException.
>> >
>> > What am I doing wrong ?
>> >
>>
>> What do you mean by doesnt allow me to?
>>
>> You should be able to do that. Are you sure an exception is not occurring?
>> You can use the tracer to see how the message is routed
>> http://camel.apache.org/tracer
>
> Sorry, I meant to say it doesn't compile.
>
> This route will not compile on Camel 2.0.0 or latest 2.1-SNAPSHOT:

Ah the reason is that the javac and generics is limited in terms of DSL wise.

What you need to do is to pass in the xpath as a 2nd parameter to setHeader.

This
   .setHeader(DOI).xpath("/ambraMessage/doi/text()", String.class)

Should be
   .setHeader(DOI, xpath("/ambraMessage/doi/text()", String.class))



>
> from("activemq:plos.pmc")
>   .to("rnc:pmc-message.rnc")
>   .setHeader(DOI).xpath("/ambraMessage/doi/text()", String.class)
>   
> .setHeader(Exchange.FILE_NAME).xpath("/ambraMessage/archive/text()",String.class)
>   .setHeader("to").xpath("/ambraMessage/pmc/mailto/text()",String.class)
>   .setHeader("CC").xpath("/ambraMessage/pmc/mailtoCC/text()",String.class)
>   
> .setHeader("from").xpath("/ambraMessage/pmc/mailtoSender/text()",String.class)
>   .to("mock:end");
>
>
> --
> Dragisa Krsmanovic
> Java Developer
> Public Library of Science
> http://www.plos.org
>
>




-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Reply via email to