You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by sacauskis <ms...@forwardslope.com> on 2013/09/04 21:47:37 UTC

HTTP endpoint

I'm trying to set up a camel end point that mimics the following curl query

*curl -k -u username:password -H "If-Modified-Since: Tue, 3 Sep 2013
18:10:00 GMT" -d "mbl-stmt=(synloader(bounding-box 90 -180 -90
180)(products(SYN)))" https://weather.server/server/cgi-bin/mcsrvr/server*

The code I've come up with so far is:

*               
from("https://weather.server/server/cgi-bin/mcsrvr/server/?authMethod=Basic&authUsername=username&authPassword=password").
                setHeader(Exchange.HTTP_METHOD,constant("GET")).
                setHeader(Exchange.HTTP_QUERY,constant("If-Modified-Since:
Tue, 3 Sep 2013 14:00:00 GMT")).
                setProperty("MBL-STMT",constant("synloader(AREA(bounding-box
-90 -180 90 180)(report-type METAR)(products(SYN)))"))
                   .to("file:data");*

That the authentication is occurring but the query parameters are not being
passed in.  What am I doing wrong?

Any help would be greatly appreciated

Mike



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

Re: HTTP endpoint

Posted by sacauskis <ms...@forwardslope.com>.
Thanks for the reply.  This is what the code ultimately looked like:

public class CamelHTTP {

	public static void main(String args[]) throws Exception {
		// create CamelContext
		final CamelContext context = new DefaultCamelContext();


		// add our route to the CamelContext
		context.addRoutes(new RouteBuilder() {
			public void configure() {


				from("direct:start")
				.setHeader(Exchange.CONTENT_TYPE,
constant("application/x-www-form-urlencoded"))	
				.setHeader(Exchange.HTTP_METHOD,constant("POST"))
				.setHeader("If-Modified-Since", constant(" Tue, 4 Sep 2013 18:10:00
GMT"))
				.setBody(constant("mbl-stmt=(synloader(bounding-box 90 -180 -90
180)(report-type BBXX)(products(SYN)))"))
			
.to("https://weather.severl/metcast/cgi-bin/mcsrvr/server?authMethod=Basic&authUsername=fusername&authPassword=password")
				.to("file:data");
			}
		});

		// start the route and let it do its work
		context.start();
		ProducerTemplate template = context.createProducerTemplate();
		template.sendBody("direct:start","");

		context.setTracing(false);
		Thread.sleep(90000);

		// stop the CamelContext
		context.stop();
	}
}



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

Re: HTTP endpoint

Posted by Willem Jiang <wi...@gmail.com>.
If you want to set the query parameters, you need to set the header before
sending the request.

the HTTP method should be POST instead of  GET, as you are send the data
"mbl-stmt=(synloader(bounding-box 90 -180 -90180)(products(SYN)))".



Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/)
(English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem


On Thu, Sep 5, 2013 at 3:47 AM, sacauskis <ms...@forwardslope.com>wrote:

> I'm trying to set up a camel end point that mimics the following curl query
>
> *curl -k -u username:password -H "If-Modified-Since: Tue, 3 Sep 2013
> 18:10:00 GMT" -d "mbl-stmt=(synloader(bounding-box 90 -180 -90
> 180)(products(SYN)))" https://weather.server/server/cgi-bin/mcsrvr/server*
>
> The code I've come up with so far is:
>
> *
> from("
> https://weather.server/server/cgi-bin/mcsrvr/server/?authMethod=Basic&authUsername=username&authPassword=password
> ").
>                 setHeader(Exchange.HTTP_METHOD,constant("GET")).
>                 setHeader(Exchange.HTTP_QUERY,constant("If-Modified-Since:
> Tue, 3 Sep 2013 14:00:00 GMT")).
>
> setProperty("MBL-STMT",constant("synloader(AREA(bounding-box
> -90 -180 90 180)(report-type METAR)(products(SYN)))"))
>                    .to("file:data");*
>
> That the authentication is occurring but the query parameters are not being
> passed in.  What am I doing wrong?
>
> Any help would be greatly appreciated
>
> Mike
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/HTTP-endpoint-tp5738701.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>