You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "M.Ismail" <mo...@gmail.com> on 2010/06/06 16:27:04 UTC

XPath expression inside doTry()

Hi all, 

I have noticed that it is not possible to put an xpath expression inside a
doTry expression:
e.g. 

        from("jetty:http://0.0.0.0:9000/")        
    	.doTry()
    	
    	.process(new Parser())
    	.convertBodyTo(String.class)
         .choice()
    	.when()
        .xpath("/ns:API[@DTC='001']",ns)
    	.process(new fwdConverter())    	
    	.setHeader("Content-Type",constant("text/xml; charset=utf-8"))
       .to("http://172.10.10.1/")
       .convertBodyTo(String.class)
    	.process(new backwdConverter())    
    	.convertBodyTo(String.class)
    	.process(new XmlEmbedder())
    	.transform(body())
    	.doCatch(IllegalInputOrProcessingException.class)
    	.process(new ExceptionProcessorHandler())
    	.transform(body())
    	.process(new XmlEmbedder())
    	.end();

I receive this following compilation error:
"The method doCatch(Class<IllegalInputOrProcessingException>) is undefined
for the type ChoiceDefinition	MyRouteBuilder.java
/Max-router/src/main/java/tutorial	line 145"


Any ideas?


-- 
View this message in context: http://old.nabble.com/XPath-expression-inside-doTry%28%29-tp28793165p28793165.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: XPath expression inside doTry()

Posted by "M.Ismail" <mo...@gmail.com>.
Thanks for your help Claus. I am now using a single onException clause with a
workaround which is setting the source endpoint type in the header so that I
can take different actions (processors) according to the message origin. Its
working fine for now and I find out that I need to handle some specific
exceptions differently I'll use doTry but for a much smaller scope.  
 

Claus Ibsen-2 wrote:
> 
> On Wed, Jun 9, 2010 at 11:13 AM, M.Ismail <mo...@gmail.com> wrote:
>>
>> Now I am getting this error:
>>
>> "The method when(XPathBuilder) is undefined for the type TryDefinition
>> MyRouteBuilder.java     /Migration-simple-router/src/main/java/tutorial
>> line
>> 135"
>> I think that it is "only" accpeted if
>> Here is my route:
>>        from("jetty:http://0.0.0.0:9000/")
>>        .doTry()
>>
>>        .process(new Parser())
>>        .convertBodyTo(String.class)
>>        .when(.when(xpath("/ns:API[@DTC=\"001\"]").namespace("ns",
>> "http://mydomain.com.eg")))
>>        .process(new fwdConverter())
>>       .setHeader("Content-Type",constant("text/xml; charset=utf-8"))
>>       .to("http://172.10.10.1/")
>>       .convertBodyTo(String.class)
>>        .process(new backwdConverter())
>>        .convertBodyTo(String.class)
>>        .process(new XmlEmbedder())
>>        .transform(body())
>>        .doCatch(IllegalInputOrProcessingException.class)
>>        .process(new ExceptionProcessorHandler())
>>        .transform(body())
>>        .process(new XmlEmbedder())
>>        .end();
>>
>> btw: if I add .choice() before when(xpath(.... then I get the old error:
>> "The method doCatch(Class<IllegalInputOrProcessingException>) is
>> undefined
>> for the type ChoiceDefinition   MyRouteBuilder.java
>> /Migration-simple-router/src/main/java/tutorial line 147"
>>
> 
> You need to end() the nested block. But we have stretched how far you
> can go with DSL like in Java.
> Java is not a good programming language for that, so you may have to
> split into smaller routes and link using direct.
> Otherwise Scala or XML allows you to structure bigger routes without
> hitting issues with the Java compiler being stupid.
> 
> 
>>
>>
>> Claus Ibsen-2 wrote:
>>>
>>> Hi
>>>
>>> The XPathBuilder have methods as well to set the namespace
>>>         xpath("/foo").namespace("pre", "http://acme/cheese");
>>>
>>>
>>>
>>> On Tue, Jun 8, 2010 at 3:36 PM, M.Ismail <mo...@gmail.com>
>>> wrote:
>>>>
>>>> Hi,
>>>>
>>>> Tried this but and it didn't work:
>>>>
>>>> 1- There is no overloaded function for xpath() that takes the namespace
>>>> as
>>>> the second argument.
>>>> 2- Still receive the same compilation error: "The method doCatch
>>>> Class<IllegalInputOrProcessingException>) is undefined> for the type
>>>> ChoiceDefinition   MyRouteBuilder.java
>>>>
>>>> What if I used OnException clause like this:
>>>> OnException(IllegalInputOrProcessingException.class)
>>>>       .process(new ExceptionProcessorHandler())
>>>>       .transform(body())
>>>>       .process(new XmlEmbedder())
>>>>
>>>> Will it behave the same?
>>>>
>>>> Thanks
>>>>
>>>>
>>>> Claus Ibsen-2 wrote:
>>>>>
>>>>> Hi
>>>>>
>>>>> Put xpath inside the when method
>>>>>     when(xpath("xxxx"))
>>>>>
>>>>> There is a XPathBuilder in builder.xml package and you can static
>>>>> import the xpath method on it.
>>>>>
>>>>>
>>>>> On Sun, Jun 6, 2010 at 4:27 PM, M.Ismail <mo...@gmail.com>
>>>>> wrote:
>>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> I have noticed that it is not possible to put an xpath expression
>>>>>> inside
>>>>>> a
>>>>>> doTry expression:
>>>>>> e.g.
>>>>>>
>>>>>>        from("jetty:http://0.0.0.0:9000/")
>>>>>>        .doTry()
>>>>>>
>>>>>>        .process(new Parser())
>>>>>>        .convertBodyTo(String.class)
>>>>>>         .choice()
>>>>>>        .when()
>>>>>>        .xpath("/ns:API[@DTC='001']",ns)
>>>>>>        .process(new fwdConverter())
>>>>>>        .setHeader("Content-Type",constant("text/xml; charset=utf-8"))
>>>>>>       .to("http://172.10.10.1/")
>>>>>>       .convertBodyTo(String.class)
>>>>>>        .process(new backwdConverter())
>>>>>>        .convertBodyTo(String.class)
>>>>>>        .process(new XmlEmbedder())
>>>>>>        .transform(body())
>>>>>>        .doCatch(IllegalInputOrProcessingException.class)
>>>>>>        .process(new ExceptionProcessorHandler())
>>>>>>        .transform(body())
>>>>>>        .process(new XmlEmbedder())
>>>>>>        .end();
>>>>>>
>>>>>> I receive this following compilation error:
>>>>>> "The method doCatch(Class<IllegalInputOrProcessingException>) is
>>>>>> undefined
>>>>>> for the type ChoiceDefinition   MyRouteBuilder.java
>>>>>> /Max-router/src/main/java/tutorial      line 145"
>>>>>>
>>>>>>
>>>>>> Any ideas?
>>>>>>
>>>>>>
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://old.nabble.com/XPath-expression-inside-doTry%28%29-tp28793165p28793165.html
>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Claus Ibsen
>>>>> Apache Camel Committer
>>>>>
>>>>> Author of Camel in Action: http://www.manning.com/ibsen/
>>>>> Open Source Integration: http://fusesource.com
>>>>> Blog: http://davsclaus.blogspot.com/
>>>>> Twitter: http://twitter.com/davsclaus
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://old.nabble.com/XPath-expression-inside-doTry%28%29-tp28793165p28817959.html
>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Author of Camel in Action: http://www.manning.com/ibsen/
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/XPath-expression-inside-doTry%28%29-tp28793165p28827784.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://old.nabble.com/XPath-expression-inside-doTry%28%29-tp28793165p28839474.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: XPath expression inside doTry()

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jun 9, 2010 at 11:13 AM, M.Ismail <mo...@gmail.com> wrote:
>
> Now I am getting this error:
>
> "The method when(XPathBuilder) is undefined for the type TryDefinition
> MyRouteBuilder.java     /Migration-simple-router/src/main/java/tutorial line
> 135"
> I think that it is "only" accpeted if
> Here is my route:
>        from("jetty:http://0.0.0.0:9000/")
>        .doTry()
>
>        .process(new Parser())
>        .convertBodyTo(String.class)
>        .when(.when(xpath("/ns:API[@DTC=\"001\"]").namespace("ns",
> "http://mydomain.com.eg")))
>        .process(new fwdConverter())
>       .setHeader("Content-Type",constant("text/xml; charset=utf-8"))
>       .to("http://172.10.10.1/")
>       .convertBodyTo(String.class)
>        .process(new backwdConverter())
>        .convertBodyTo(String.class)
>        .process(new XmlEmbedder())
>        .transform(body())
>        .doCatch(IllegalInputOrProcessingException.class)
>        .process(new ExceptionProcessorHandler())
>        .transform(body())
>        .process(new XmlEmbedder())
>        .end();
>
> btw: if I add .choice() before when(xpath(.... then I get the old error:
> "The method doCatch(Class<IllegalInputOrProcessingException>) is undefined
> for the type ChoiceDefinition   MyRouteBuilder.java
> /Migration-simple-router/src/main/java/tutorial line 147"
>

You need to end() the nested block. But we have stretched how far you
can go with DSL like in Java.
Java is not a good programming language for that, so you may have to
split into smaller routes and link using direct.
Otherwise Scala or XML allows you to structure bigger routes without
hitting issues with the Java compiler being stupid.


>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> The XPathBuilder have methods as well to set the namespace
>>         xpath("/foo").namespace("pre", "http://acme/cheese");
>>
>>
>>
>> On Tue, Jun 8, 2010 at 3:36 PM, M.Ismail <mo...@gmail.com> wrote:
>>>
>>> Hi,
>>>
>>> Tried this but and it didn't work:
>>>
>>> 1- There is no overloaded function for xpath() that takes the namespace
>>> as
>>> the second argument.
>>> 2- Still receive the same compilation error: "The method doCatch
>>> Class<IllegalInputOrProcessingException>) is undefined> for the type
>>> ChoiceDefinition   MyRouteBuilder.java
>>>
>>> What if I used OnException clause like this:
>>> OnException(IllegalInputOrProcessingException.class)
>>>       .process(new ExceptionProcessorHandler())
>>>       .transform(body())
>>>       .process(new XmlEmbedder())
>>>
>>> Will it behave the same?
>>>
>>> Thanks
>>>
>>>
>>> Claus Ibsen-2 wrote:
>>>>
>>>> Hi
>>>>
>>>> Put xpath inside the when method
>>>>     when(xpath("xxxx"))
>>>>
>>>> There is a XPathBuilder in builder.xml package and you can static
>>>> import the xpath method on it.
>>>>
>>>>
>>>> On Sun, Jun 6, 2010 at 4:27 PM, M.Ismail <mo...@gmail.com>
>>>> wrote:
>>>>>
>>>>> Hi all,
>>>>>
>>>>> I have noticed that it is not possible to put an xpath expression
>>>>> inside
>>>>> a
>>>>> doTry expression:
>>>>> e.g.
>>>>>
>>>>>        from("jetty:http://0.0.0.0:9000/")
>>>>>        .doTry()
>>>>>
>>>>>        .process(new Parser())
>>>>>        .convertBodyTo(String.class)
>>>>>         .choice()
>>>>>        .when()
>>>>>        .xpath("/ns:API[@DTC='001']",ns)
>>>>>        .process(new fwdConverter())
>>>>>        .setHeader("Content-Type",constant("text/xml; charset=utf-8"))
>>>>>       .to("http://172.10.10.1/")
>>>>>       .convertBodyTo(String.class)
>>>>>        .process(new backwdConverter())
>>>>>        .convertBodyTo(String.class)
>>>>>        .process(new XmlEmbedder())
>>>>>        .transform(body())
>>>>>        .doCatch(IllegalInputOrProcessingException.class)
>>>>>        .process(new ExceptionProcessorHandler())
>>>>>        .transform(body())
>>>>>        .process(new XmlEmbedder())
>>>>>        .end();
>>>>>
>>>>> I receive this following compilation error:
>>>>> "The method doCatch(Class<IllegalInputOrProcessingException>) is
>>>>> undefined
>>>>> for the type ChoiceDefinition   MyRouteBuilder.java
>>>>> /Max-router/src/main/java/tutorial      line 145"
>>>>>
>>>>>
>>>>> Any ideas?
>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://old.nabble.com/XPath-expression-inside-doTry%28%29-tp28793165p28793165.html
>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Claus Ibsen
>>>> Apache Camel Committer
>>>>
>>>> Author of Camel in Action: http://www.manning.com/ibsen/
>>>> Open Source Integration: http://fusesource.com
>>>> Blog: http://davsclaus.blogspot.com/
>>>> Twitter: http://twitter.com/davsclaus
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/XPath-expression-inside-doTry%28%29-tp28793165p28817959.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> --
> View this message in context: http://old.nabble.com/XPath-expression-inside-doTry%28%29-tp28793165p28827784.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: XPath expression inside doTry()

Posted by "M.Ismail" <mo...@gmail.com>.
Now I am getting this error: 

"The method when(XPathBuilder) is undefined for the type TryDefinition
MyRouteBuilder.java	/Migration-simple-router/src/main/java/tutorial	line
135"
I think that it is "only" accpeted if 
Here is my route:
        from("jetty:http://0.0.0.0:9000/")
        .doTry()

        .process(new Parser())
        .convertBodyTo(String.class)
        .when(.when(xpath("/ns:API[@DTC=\"001\"]").namespace("ns",
"http://mydomain.com.eg")))
        .process(new fwdConverter())
       .setHeader("Content-Type",constant("text/xml; charset=utf-8"))
       .to("http://172.10.10.1/")
       .convertBodyTo(String.class)
        .process(new backwdConverter())
        .convertBodyTo(String.class)
        .process(new XmlEmbedder())
        .transform(body())
        .doCatch(IllegalInputOrProcessingException.class)
        .process(new ExceptionProcessorHandler())
        .transform(body())
        .process(new XmlEmbedder())
        .end();

btw: if I add .choice() before when(xpath(.... then I get the old error:
"The method doCatch(Class<IllegalInputOrProcessingException>) is undefined
for the type ChoiceDefinition	MyRouteBuilder.java
/Migration-simple-router/src/main/java/tutorial	line 147"



Claus Ibsen-2 wrote:
> 
> Hi
> 
> The XPathBuilder have methods as well to set the namespace
>         xpath("/foo").namespace("pre", "http://acme/cheese");
> 
> 
> 
> On Tue, Jun 8, 2010 at 3:36 PM, M.Ismail <mo...@gmail.com> wrote:
>>
>> Hi,
>>
>> Tried this but and it didn't work:
>>
>> 1- There is no overloaded function for xpath() that takes the namespace
>> as
>> the second argument.
>> 2- Still receive the same compilation error: "The method doCatch
>> Class<IllegalInputOrProcessingException>) is undefined> for the type
>> ChoiceDefinition   MyRouteBuilder.java
>>
>> What if I used OnException clause like this:
>> OnException(IllegalInputOrProcessingException.class)
>>       .process(new ExceptionProcessorHandler())
>>       .transform(body())
>>       .process(new XmlEmbedder())
>>
>> Will it behave the same?
>>
>> Thanks
>>
>>
>> Claus Ibsen-2 wrote:
>>>
>>> Hi
>>>
>>> Put xpath inside the when method
>>>     when(xpath("xxxx"))
>>>
>>> There is a XPathBuilder in builder.xml package and you can static
>>> import the xpath method on it.
>>>
>>>
>>> On Sun, Jun 6, 2010 at 4:27 PM, M.Ismail <mo...@gmail.com>
>>> wrote:
>>>>
>>>> Hi all,
>>>>
>>>> I have noticed that it is not possible to put an xpath expression
>>>> inside
>>>> a
>>>> doTry expression:
>>>> e.g.
>>>>
>>>>        from("jetty:http://0.0.0.0:9000/")
>>>>        .doTry()
>>>>
>>>>        .process(new Parser())
>>>>        .convertBodyTo(String.class)
>>>>         .choice()
>>>>        .when()
>>>>        .xpath("/ns:API[@DTC='001']",ns)
>>>>        .process(new fwdConverter())
>>>>        .setHeader("Content-Type",constant("text/xml; charset=utf-8"))
>>>>       .to("http://172.10.10.1/")
>>>>       .convertBodyTo(String.class)
>>>>        .process(new backwdConverter())
>>>>        .convertBodyTo(String.class)
>>>>        .process(new XmlEmbedder())
>>>>        .transform(body())
>>>>        .doCatch(IllegalInputOrProcessingException.class)
>>>>        .process(new ExceptionProcessorHandler())
>>>>        .transform(body())
>>>>        .process(new XmlEmbedder())
>>>>        .end();
>>>>
>>>> I receive this following compilation error:
>>>> "The method doCatch(Class<IllegalInputOrProcessingException>) is
>>>> undefined
>>>> for the type ChoiceDefinition   MyRouteBuilder.java
>>>> /Max-router/src/main/java/tutorial      line 145"
>>>>
>>>>
>>>> Any ideas?
>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://old.nabble.com/XPath-expression-inside-doTry%28%29-tp28793165p28793165.html
>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Author of Camel in Action: http://www.manning.com/ibsen/
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/XPath-expression-inside-doTry%28%29-tp28793165p28817959.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://old.nabble.com/XPath-expression-inside-doTry%28%29-tp28793165p28827784.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: XPath expression inside doTry()

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

The XPathBuilder have methods as well to set the namespace
        xpath("/foo").namespace("pre", "http://acme/cheese");



On Tue, Jun 8, 2010 at 3:36 PM, M.Ismail <mo...@gmail.com> wrote:
>
> Hi,
>
> Tried this but and it didn't work:
>
> 1- There is no overloaded function for xpath() that takes the namespace as
> the second argument.
> 2- Still receive the same compilation error: "The method doCatch
> Class<IllegalInputOrProcessingException>) is undefined> for the type
> ChoiceDefinition   MyRouteBuilder.java
>
> What if I used OnException clause like this:
> OnException(IllegalInputOrProcessingException.class)
>       .process(new ExceptionProcessorHandler())
>       .transform(body())
>       .process(new XmlEmbedder())
>
> Will it behave the same?
>
> Thanks
>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> Put xpath inside the when method
>>     when(xpath("xxxx"))
>>
>> There is a XPathBuilder in builder.xml package and you can static
>> import the xpath method on it.
>>
>>
>> On Sun, Jun 6, 2010 at 4:27 PM, M.Ismail <mo...@gmail.com> wrote:
>>>
>>> Hi all,
>>>
>>> I have noticed that it is not possible to put an xpath expression inside
>>> a
>>> doTry expression:
>>> e.g.
>>>
>>>        from("jetty:http://0.0.0.0:9000/")
>>>        .doTry()
>>>
>>>        .process(new Parser())
>>>        .convertBodyTo(String.class)
>>>         .choice()
>>>        .when()
>>>        .xpath("/ns:API[@DTC='001']",ns)
>>>        .process(new fwdConverter())
>>>        .setHeader("Content-Type",constant("text/xml; charset=utf-8"))
>>>       .to("http://172.10.10.1/")
>>>       .convertBodyTo(String.class)
>>>        .process(new backwdConverter())
>>>        .convertBodyTo(String.class)
>>>        .process(new XmlEmbedder())
>>>        .transform(body())
>>>        .doCatch(IllegalInputOrProcessingException.class)
>>>        .process(new ExceptionProcessorHandler())
>>>        .transform(body())
>>>        .process(new XmlEmbedder())
>>>        .end();
>>>
>>> I receive this following compilation error:
>>> "The method doCatch(Class<IllegalInputOrProcessingException>) is
>>> undefined
>>> for the type ChoiceDefinition   MyRouteBuilder.java
>>> /Max-router/src/main/java/tutorial      line 145"
>>>
>>>
>>> Any ideas?
>>>
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/XPath-expression-inside-doTry%28%29-tp28793165p28793165.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> --
> View this message in context: http://old.nabble.com/XPath-expression-inside-doTry%28%29-tp28793165p28817959.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: XPath expression inside doTry()

Posted by "M.Ismail" <mo...@gmail.com>.
Hi, 

Tried this but and it didn't work:

1- There is no overloaded function for xpath() that takes the namespace as
the second argument.
2- Still receive the same compilation error: "The method doCatch
Class<IllegalInputOrProcessingException>) is undefined> for the type
ChoiceDefinition   MyRouteBuilder.java

What if I used OnException clause like this:
OnException(IllegalInputOrProcessingException.class)
       .process(new ExceptionProcessorHandler())
       .transform(body())
       .process(new XmlEmbedder())

Will it behave the same?

Thanks


Claus Ibsen-2 wrote:
> 
> Hi
> 
> Put xpath inside the when method
>     when(xpath("xxxx"))
> 
> There is a XPathBuilder in builder.xml package and you can static
> import the xpath method on it.
> 
> 
> On Sun, Jun 6, 2010 at 4:27 PM, M.Ismail <mo...@gmail.com> wrote:
>>
>> Hi all,
>>
>> I have noticed that it is not possible to put an xpath expression inside
>> a
>> doTry expression:
>> e.g.
>>
>>        from("jetty:http://0.0.0.0:9000/")
>>        .doTry()
>>
>>        .process(new Parser())
>>        .convertBodyTo(String.class)
>>         .choice()
>>        .when()
>>        .xpath("/ns:API[@DTC='001']",ns)
>>        .process(new fwdConverter())
>>        .setHeader("Content-Type",constant("text/xml; charset=utf-8"))
>>       .to("http://172.10.10.1/")
>>       .convertBodyTo(String.class)
>>        .process(new backwdConverter())
>>        .convertBodyTo(String.class)
>>        .process(new XmlEmbedder())
>>        .transform(body())
>>        .doCatch(IllegalInputOrProcessingException.class)
>>        .process(new ExceptionProcessorHandler())
>>        .transform(body())
>>        .process(new XmlEmbedder())
>>        .end();
>>
>> I receive this following compilation error:
>> "The method doCatch(Class<IllegalInputOrProcessingException>) is
>> undefined
>> for the type ChoiceDefinition   MyRouteBuilder.java
>> /Max-router/src/main/java/tutorial      line 145"
>>
>>
>> Any ideas?
>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/XPath-expression-inside-doTry%28%29-tp28793165p28793165.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://old.nabble.com/XPath-expression-inside-doTry%28%29-tp28793165p28817959.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: XPath expression inside doTry()

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Put xpath inside the when method
    when(xpath("xxxx"))

There is a XPathBuilder in builder.xml package and you can static
import the xpath method on it.


On Sun, Jun 6, 2010 at 4:27 PM, M.Ismail <mo...@gmail.com> wrote:
>
> Hi all,
>
> I have noticed that it is not possible to put an xpath expression inside a
> doTry expression:
> e.g.
>
>        from("jetty:http://0.0.0.0:9000/")
>        .doTry()
>
>        .process(new Parser())
>        .convertBodyTo(String.class)
>         .choice()
>        .when()
>        .xpath("/ns:API[@DTC='001']",ns)
>        .process(new fwdConverter())
>        .setHeader("Content-Type",constant("text/xml; charset=utf-8"))
>       .to("http://172.10.10.1/")
>       .convertBodyTo(String.class)
>        .process(new backwdConverter())
>        .convertBodyTo(String.class)
>        .process(new XmlEmbedder())
>        .transform(body())
>        .doCatch(IllegalInputOrProcessingException.class)
>        .process(new ExceptionProcessorHandler())
>        .transform(body())
>        .process(new XmlEmbedder())
>        .end();
>
> I receive this following compilation error:
> "The method doCatch(Class<IllegalInputOrProcessingException>) is undefined
> for the type ChoiceDefinition   MyRouteBuilder.java
> /Max-router/src/main/java/tutorial      line 145"
>
>
> Any ideas?
>
>
> --
> View this message in context: http://old.nabble.com/XPath-expression-inside-doTry%28%29-tp28793165p28793165.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus