You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Ishada <ab...@gmail.com> on 2015/10/28 17:33:36 UTC

HTTPS Endpoint to File

I need to access a HTTPS Resource which is using Basic Authentication and It
is a GET Resource. I have written a code in java using URIBuilder and adding
the username, password etc as Headers to the URIBuilder and using Apache
HTTP Client to access the resource and it is working well. Now my
requirement is to implement the same functionality using Apache Camel, Well
I tried using Camel HTTP component and by using Java DSL, But the problem is
I am just able to provide the URI. But how can I add various Headers to this
URI ?.



--
View this message in context: http://camel.465427.n5.nabble.com/HTTPS-Endpoint-to-File-tp5773160.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: HTTPS Endpoint to File

Posted by Claus Ibsen <cl...@gmail.com>.
See the authentication and proxy section at
http://camel.apache.org/http

You can set the auth to basic and username/password

On Thu, Oct 29, 2015 at 7:41 AM, Ishada <ab...@gmail.com> wrote:
> They are HTTP headers. I have tried to implement it as follows but it is
> still not working
>
> from("direct:start")
>                                                 .setHeader(Exchange.HTTP_METHOD, constant("GET"))
>                                                 .process(new Processor() {
>                                                         public void process(Exchange exchange)
>                                                                         throws Exception {
>                                                                 System.out.println("Hi From Processor");
>                                                                 HttpBasicAuthRestClient http = new HttpBasicAuthRestClient(
>                                                                                 "https://someurl",
>                                                                                 "", "",
>                                                                                 "");
>                                                                 exchange.getIn()
>                                                                                 .setHeaders(http.getHeaderMap());
>
>                                                         }
>                                                 })
>                                                 .to("https4://someurl")
>                                                 .process(new Processor() {
>                                                         public void process(Exchange exchange)
>                                                                         throws Exception {
>                                                                 System.out.println(exchange.getIn().getBody()
>                                                                                 .toString());
>
>                                                         }
>                                                 });
>  I am not getting anything on the console.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/HTTPS-Endpoint-to-File-tp5773160p5773175.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2nd edition:
https://www.manning.com/books/camel-in-action-second-edition

Re: HTTPS Endpoint to File

Posted by Ishada <ab...@gmail.com>.
They are HTTP headers. I have tried to implement it as follows but it is
still not working

from("direct:start")
						.setHeader(Exchange.HTTP_METHOD, constant("GET"))
						.process(new Processor() {
							public void process(Exchange exchange)
									throws Exception {
								System.out.println("Hi From Processor");
								HttpBasicAuthRestClient http = new HttpBasicAuthRestClient(
										"https://someurl",
										"", "",
										"");
								exchange.getIn()
										.setHeaders(http.getHeaderMap());

							}
						})
						.to("https4://someurl")
						.process(new Processor() {
							public void process(Exchange exchange)
									throws Exception {
								System.out.println(exchange.getIn().getBody()
										.toString());

							}
						});
 I am not getting anything on the console.



--
View this message in context: http://camel.465427.n5.nabble.com/HTTPS-Endpoint-to-File-tp5773160p5773175.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: HTTPS Endpoint to File

Posted by Claus Ibsen <cl...@gmail.com>.
What headers do you want to add? Are they to be HTTP query parameters?
or HTTP headers?

For dynamic uri's see this FAQ
http://camel.apache.org/how-to-use-a-dynamic-uri-in-to.html

And an alternative is that the http component allows to specify the
query parameters in a special header named Exchange.HTTP_QUERY so you
can keep the http endpoint uri constant.



On Wed, Oct 28, 2015 at 5:33 PM, Ishada <ab...@gmail.com> wrote:
> I need to access a HTTPS Resource which is using Basic Authentication and It
> is a GET Resource. I have written a code in java using URIBuilder and adding
> the username, password etc as Headers to the URIBuilder and using Apache
> HTTP Client to access the resource and it is working well. Now my
> requirement is to implement the same functionality using Apache Camel, Well
> I tried using Camel HTTP component and by using Java DSL, But the problem is
> I am just able to provide the URI. But how can I add various Headers to this
> URI ?.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/HTTPS-Endpoint-to-File-tp5773160.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2nd edition:
https://www.manning.com/books/camel-in-action-second-edition