You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by soumya_sd <so...@yahoo.com> on 2012/03/16 00:04:29 UTC

Why this works with Spring DSL and not Java DSL - http component

I'm trying to integrate Google Places API using Apache Camel (2.10-SNAPSHOT)
and Spring (3.0.7.RELEASE) with Tomcat (7.0.26) as my web conainer server.

When I declare the route in a Spring config xml (see below) I can see the
correct output response on my Tomcat logs.


 <route id="google-places-route">
        <from uri="direct:start" />
        <to
uri="https://maps.googleapis.com/maps/api/place/search/json?location=40.446788,-79.950559&amp;radius=500&amp;types=food&amp;sensor=false&amp;key=my-google-api-key"
/>
        <to uri="stream:out"/>
        </split>        
</route>

Please note the camel scheme used here is https and NOT http.

Now, I'm trying to do the same by defining my route in a Java class that
extends RouterBuilder

public class GooglePlacesRoute extends RouteBuilder {

 @Override
public void configure() throws Exception {

    from("direct:start").process(new
MyCustomProcessor()).to("https://maps.googleapis.com/maps/api/place/search/json?location=40.446788,-79.950559&amp;radius=500&amp;types=food&amp;sensor=false&amp;key=my-google-api-key").to("stream:out");
}
}

class MyCustomProcessor implements Processor {

@Override
public void process(Exchange exchange) throws Exception {

    exchange.setPattern(ExchangePattern.InOut);
        Message inMessage = exchange.getIn();


    inMessage.setHeader(Exchange.HTTP_METHOD, "GET");
    exchange.getIn().setBody("", String.class);

}
}

My Camel route is deployed and started correctly. However, when I invoked it
I don't get the expected output. I get the following response from Google's
servers.

{ "html_attributions" : [], "results" : [], "status" : "REQUEST_DENIED" }

I'm assuming that I don't have to do anything special in my Java DSL to
handle HTTPS (instead of HTTP). Is this assumption correct ?

What am I missing here ?

Thanks.

--
View this message in context: http://camel.465427.n5.nabble.com/Why-this-works-with-Spring-DSL-and-not-Java-DSL-http-component-tp5569500p5569500.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Why this works with Spring DSL and not Java DSL - http component

Posted by soumya_sd <so...@yahoo.com>.
I'm using "&amp;" in my Spring XML. My Spring routes works. The Java DSL
version of the same route is not working.  

--
View this message in context: http://camel.465427.n5.nabble.com/Why-this-works-with-Spring-DSL-and-not-Java-DSL-http-component-tp5569500p5569542.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Why this works with Spring DSL and not Java DSL - http component

Posted by Christian Müller <ch...@gmail.com>.
In your XML/Spring route definition, you have to use "&amp;" instead of "&".

Best,
Christian

On Fri, Mar 16, 2012 at 12:04 AM, soumya_sd <so...@yahoo.com> wrote:

> I'm trying to integrate Google Places API using Apache Camel
> (2.10-SNAPSHOT)
> and Spring (3.0.7.RELEASE) with Tomcat (7.0.26) as my web conainer server.
>
> When I declare the route in a Spring config xml (see below) I can see the
> correct output response on my Tomcat logs.
>
>
>  <route id="google-places-route">
>        <from uri="direct:start" />
>        <to
> uri="
> https://maps.googleapis.com/maps/api/place/search/json?location=40.446788,-79.950559&radius=500&types=food&sensor=false&key=my-google-api-key
> "
> />
>        <to uri="stream:out"/>
>        </split>
> </route>
>
> Please note the camel scheme used here is https and NOT http.
>
> Now, I'm trying to do the same by defining my route in a Java class that
> extends RouterBuilder
>
> public class GooglePlacesRoute extends RouteBuilder {
>
>  @Override
> public void configure() throws Exception {
>
>    from("direct:start").process(new
> MyCustomProcessor()).to("
> https://maps.googleapis.com/maps/api/place/search/json?location=40.446788,-79.950559&radius=500&types=food&sensor=false&key=my-google-api-key
> ").to("stream:out");
> }
> }
>
> class MyCustomProcessor implements Processor {
>
> @Override
> public void process(Exchange exchange) throws Exception {
>
>    exchange.setPattern(ExchangePattern.InOut);
>        Message inMessage = exchange.getIn();
>
>
>    inMessage.setHeader(Exchange.HTTP_METHOD, "GET");
>    exchange.getIn().setBody("", String.class);
>
> }
> }
>
> My Camel route is deployed and started correctly. However, when I invoked
> it
> I don't get the expected output. I get the following response from Google's
> servers.
>
> { "html_attributions" : [], "results" : [], "status" : "REQUEST_DENIED" }
>
> I'm assuming that I don't have to do anything special in my Java DSL to
> handle HTTPS (instead of HTTP). Is this assumption correct ?
>
> What am I missing here ?
>
> Thanks.
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Why-this-works-with-Spring-DSL-and-not-Java-DSL-http-component-tp5569500p5569500.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Why this works with Spring DSL and not Java DSL - http component

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Mar 16, 2012 at 12:07 PM, soumya_sd <so...@yahoo.com> wrote:
>
>
>
> Claus Ibsen-2 wrote
>>
>> Hi
>>
>> This is also posted as Q on stackoverflow, which is answered there
>> http://stackoverflow.com/questions/9728604/apache-camel-simple-https-google-places-call-difference-between-spring-dsl-a
>>
>> Please when you ask for help on multiple channels, then mention that
>> you do that.
>> This help keep the conversation at one place and ppl can see what is going
>> on.
>>
>>
>
> Claus, I'm new to Camel and this forum. I was not sure if everyone followed
> at both forums, hence the duplicate postings. In the future, I'll post in on
> forum and put a link on the other.
>
> I was also going to update this thread with the solution (that you have
> already linked to above.)
>

No worries, we are just seeing an uptake on this as stackoverflow is
becoming more popular as well.
So its harder for people to help, and also for people who google, may
only fine the question in one channel.
Where as we help answer the question on another channel. And then
those users cannot find the answer on the 2nd channel etc.


> BTW, I'm also reading your book and find it helpful as a Camel newbie.
>
> Thanks.
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Why-this-works-with-Spring-DSL-and-not-Java-DSL-http-component-tp5569500p5570923.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
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/

Re: Why this works with Spring DSL and not Java DSL - http component

Posted by soumya_sd <so...@yahoo.com>.


Claus Ibsen-2 wrote
> 
> Hi
> 
> This is also posted as Q on stackoverflow, which is answered there
> http://stackoverflow.com/questions/9728604/apache-camel-simple-https-google-places-call-difference-between-spring-dsl-a
> 
> Please when you ask for help on multiple channels, then mention that
> you do that.
> This help keep the conversation at one place and ppl can see what is going
> on.
> 
> 

Claus, I'm new to Camel and this forum. I was not sure if everyone followed
at both forums, hence the duplicate postings. In the future, I'll post in on
forum and put a link on the other. 

I was also going to update this thread with the solution (that you have
already linked to above.) 

BTW, I'm also reading your book and find it helpful as a Camel newbie. 

Thanks. 

--
View this message in context: http://camel.465427.n5.nabble.com/Why-this-works-with-Spring-DSL-and-not-Java-DSL-http-component-tp5569500p5570923.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Why this works with Spring DSL and not Java DSL - http component

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

This is also posted as Q on stackoverflow, which is answered there
http://stackoverflow.com/questions/9728604/apache-camel-simple-https-google-places-call-difference-between-spring-dsl-a

Please when you ask for help on multiple channels, then mention that
you do that.
This help keep the conversation at one place and ppl can see what is going on.



On Fri, Mar 16, 2012 at 12:04 AM, soumya_sd <so...@yahoo.com> wrote:
> I'm trying to integrate Google Places API using Apache Camel (2.10-SNAPSHOT)
> and Spring (3.0.7.RELEASE) with Tomcat (7.0.26) as my web conainer server.
>
> When I declare the route in a Spring config xml (see below) I can see the
> correct output response on my Tomcat logs.
>
>
>  <route id="google-places-route">
>        <from uri="direct:start" />
>        <to
> uri="https://maps.googleapis.com/maps/api/place/search/json?location=40.446788,-79.950559&radius=500&types=food&sensor=false&key=my-google-api-key"
> />
>        <to uri="stream:out"/>
>        </split>
> </route>
>
> Please note the camel scheme used here is https and NOT http.
>
> Now, I'm trying to do the same by defining my route in a Java class that
> extends RouterBuilder
>
> public class GooglePlacesRoute extends RouteBuilder {
>
>  @Override
> public void configure() throws Exception {
>
>    from("direct:start").process(new
> MyCustomProcessor()).to("https://maps.googleapis.com/maps/api/place/search/json?location=40.446788,-79.950559&radius=500&types=food&sensor=false&key=my-google-api-key").to("stream:out");
> }
> }
>
> class MyCustomProcessor implements Processor {
>
> @Override
> public void process(Exchange exchange) throws Exception {
>
>    exchange.setPattern(ExchangePattern.InOut);
>        Message inMessage = exchange.getIn();
>
>
>    inMessage.setHeader(Exchange.HTTP_METHOD, "GET");
>    exchange.getIn().setBody("", String.class);
>
> }
> }
>
> My Camel route is deployed and started correctly. However, when I invoked it
> I don't get the expected output. I get the following response from Google's
> servers.
>
> { "html_attributions" : [], "results" : [], "status" : "REQUEST_DENIED" }
>
> I'm assuming that I don't have to do anything special in my Java DSL to
> handle HTTPS (instead of HTTP). Is this assumption correct ?
>
> What am I missing here ?
>
> Thanks.
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Why-this-works-with-Spring-DSL-and-not-Java-DSL-http-component-tp5569500p5569500.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/