You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Manoj Kolhe <ha...@gmail.com> on 2013/01/11 11:48:04 UTC

Camel Spring XML

Hi,

I am a newbie using Apache Camel.

I am trying to configure 2 different routes based on the servlet example in
the package.

My route configuration looks as below:

<camel:route id="route1">
  	<camel:from uri="servlet:///hello"/>
  		<camel:choice>	
  			<camel:when>
  				<camel:header>name</camel:header>
  				<camel:transform>
  					<camel:simple>Hello ${header.name} world</camel:simple>
  				</camel:transform>
  			</camel:when>
  			<camel:otherwise>
  				<camel:to
uri="http://localhost:8080?&amp;bridgeEndpoint=true&amp;throwExceptionOnFailure=false"/>
  			</camel:otherwise>
  		</camel:choice>
  	
  </camel:route>
  
  
  
 <camel:route id="route2">
  	<camel:from uri="servlet:///helloWorld"/>
  		<camel:choice>	
  			<camel:when>
  				<camel:header>name</camel:header>
  				<camel:transform>
  					<camel:simple>Hello ${header.name} world</camel:simple>
  				</camel:transform>
  			</camel:when>
  			<camel:otherwise>
  				<camel:to
uri="http://10.74.81.81:8080?bridgeEndpoint=true&amp;throwExceptionOnFailure=false"/>
  			</camel:otherwise>
  		</camel:choice>
  	
  </camel:route>



I wish to pass parameters and somewhere for to:uri servlet path which I read
from somewhere can be done as
servletName[?requestParameter1=parameterValue1&requestParameter2=....] 

When tried using above, I get xml parsing exception while loading the
application.

Can please suggest how to pass parameters at runtime?

Thanks in advance,
Manoj Kolhe



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Spring-XML-tp5725366.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Spring XML

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jan 15, 2013 at 9:32 AM, Manoj Kolhe <ha...@gmail.com> wrote:
> Now the next question on my mind,
>
> This is plain example for fetching request parameters as GET method.
>
> How to pass the parameters to as POST?
>

Why dont you try sending a HTTP POST to the Camel servlet and see what happens.


>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Spring-XML-tp5725366p5725569.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Camel Spring XML

Posted by Manoj Kolhe <ha...@gmail.com>.
Now the next question on my mind,

This is plain example for fetching request parameters as GET method.

How to pass the parameters to as POST?




--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Spring-XML-tp5725366p5725569.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Spring XML

Posted by Manoj Kolhe <ha...@gmail.com>.
Thanks a lot!!

Issue resolved 

Cheers,
Manoj



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Spring-XML-tp5725366p5725568.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Spring XML

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jan 15, 2013 at 7:55 AM, Manoj Kolhe <ha...@gmail.com> wrote:
> Hi Claus,
>
> Thanks, I referred to the example stated on the link you have provided.
>
> Apologies to ask you a very basic question in this case:
>
>
> <choice>
>         <when>
>
>           <header>name</header>
>
>           <transform>
>             <simple>Hello ${header.name} how are you?</simple>
>           </transform>
>         </when>
>
>
> In above 'choice when' code, how to associate header with key name?
>

<header>name</header>

is evaluated as if there is a header with the key name or not, and if
there is a header, then its value is != null.


> As I executed the code provided on the link and it is always executing the
> 'choice-otherwise' segment.
>

If you run this example
http://camel.apache.org/servlet-tomcat-example.html

It outputs in the webpage how to provide a name, eg by adding ?name=Claus
to the http url in your web browser.


> Thanks in advance,
> Manoj
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Spring-XML-tp5725366p5725561.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Camel Spring XML

Posted by Manoj Kolhe <ha...@gmail.com>.
Hi Claus,

Thanks, I referred to the example stated on the link you have provided.

Apologies to ask you a very basic question in this case:


<choice>
        <when>
          
          <header>name</header>
          
          <transform>
            <simple>Hello ${header.name} how are you?</simple>
          </transform>
        </when>


In above 'choice when' code, how to associate header with key name?

As I executed the code provided on the link and it is always executing the
'choice-otherwise' segment.

Thanks in advance,
Manoj



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Spring-XML-tp5725366p5725561.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Spring XML

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Jan 11, 2013 at 3:46 PM, Manoj Kolhe <ha...@gmail.com> wrote:
> Hi Claus,
>
> Thanks for quick revert.
>
> I resolved the issue of passing parameters in <camel:to uri="http...">
>
>
> Current Issue:
> Now the main thing to me is how to receive parameters from <camel:from
> uri="servlet:///helloWorld"> path
>
> When created from path as <camel:from uri="servlet://helloWorld?name=test">
> it gives XML error.
>

You cannot set hardcoded http request paramters on the servlet component.
Its the HTTP client that can send request parameters when it calls the
HTTP service

See this example
http://camel.apache.org/servlet-tomcat-example.html


> Can please suggest what should be the correct way to pass parameters from
> 'from' tag?
>
> Thanks in advance,
> Manoj
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Spring-XML-tp5725366p5725394.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Camel Spring XML

Posted by Manoj Kolhe <ha...@gmail.com>.
Hi Claus,

Thanks for quick revert.

I resolved the issue of passing parameters in <camel:to uri="http..."> 


Current Issue:
Now the main thing to me is how to receive parameters from <camel:from
uri="servlet:///helloWorld"> path

When created from path as <camel:from uri="servlet://helloWorld?name=test">
it gives XML error.

Can please suggest what should be the correct way to pass parameters from
'from' tag?

Thanks in advance,
Manoj



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Spring-XML-tp5725366p5725394.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Spring XML

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Jan 11, 2013 at 11:48 AM, Manoj Kolhe <ha...@gmail.com> wrote:
> Hi,
>
> I am a newbie using Apache Camel.
>
> I am trying to configure 2 different routes based on the servlet example in
> the package.
>
> My route configuration looks as below:
>
> <camel:route id="route1">
>         <camel:from uri="servlet:///hello"/>
>                 <camel:choice>
>                         <camel:when>
>                                 <camel:header>name</camel:header>
>                                 <camel:transform>
>                                         <camel:simple>Hello ${header.name} world</camel:simple>
>                                 </camel:transform>
>                         </camel:when>
>                         <camel:otherwise>
>                                 <camel:to
> uri="http://localhost:8080?&amp;bridgeEndpoint=true&amp;throwExceptionOnFailure=false"/>
>                         </camel:otherwise>
>                 </camel:choice>
>
>   </camel:route>
>
>
>
>  <camel:route id="route2">
>         <camel:from uri="servlet:///helloWorld"/>
>                 <camel:choice>
>                         <camel:when>
>                                 <camel:header>name</camel:header>
>                                 <camel:transform>
>                                         <camel:simple>Hello ${header.name} world</camel:simple>
>                                 </camel:transform>
>                         </camel:when>
>                         <camel:otherwise>
>                                 <camel:to
> uri="http://10.74.81.81:8080?bridgeEndpoint=true&amp;throwExceptionOnFailure=false"/>
>                         </camel:otherwise>
>                 </camel:choice>
>
>   </camel:route>
>
>
>
> I wish to pass parameters and somewhere for to:uri servlet path which I read
> from somewhere can be done as
> servletName[?requestParameter1=parameterValue1&requestParameter2=....]
>
> When tried using above, I get xml parsing exception while loading the
> application.
>

In XML the & should be defined as &amp;
If not you can get xml parsing errors.


> Can please suggest how to pass parameters at runtime?
>
> Thanks in advance,
> Manoj Kolhe
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Spring-XML-tp5725366.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen