Sikorski
Sikorski

Reputation: 2691

Apache Camel : Proxy code

I am trying to connect to Google Api through my java code and i am using apache camel for this. i have to first authenticate on a proxy server and then the request will be forwarded to google. But, i am not able to acheive authentication though i am giving in my credentials.

context.getProperties().put("http.proxyAuthMethod","Digest");
            context.getProperties().put("http.proxyHost", "foo");
            context.getProperties().put("http.proxyPort", "80");
            context.getProperties().put("http.proxyAuthUsername",
                    "bar");
            context.getProperties().put("http.proxyAuthPassword", "foo");

also i tried with HTTP Endpoint

HttpEndpoint endpoint = (HttpEndpoint) context.getEndpoint("https://foo/bar"); 
Map<String, Object> options = new HashMap<String, Object>();
            options.put("proxyAuthUsername","foo");
            options.put("proxyAuthPassword","bar");
            options.put("proxyAuthMethod","Basic");
            endpoint.configureProperties(options);
            endpoint.setProxyHost("foo");
            endpoint.setProxyPort(80);

Still i get 407 response code, and a message that require authentication from the proxy. Can anyone please give me pointers regarding this.

Thanks

Upvotes: 0

Views: 1992

Answers (1)

Sikorski
Sikorski

Reputation: 2691

Finally i got proxy code working last night, though i dont know why the above two approaches are not working. But I started using Spring XML config files for camel routing and I was able to achieve this by the following configuration :

<camel:to uri="http://www.google.com/search?proxyAuthMethod=Basic&amp;proxyPort=xx&amp;proxyHost=xxxxxxx&amp;proxyAuthUsername=username&amp;proxyAuthPassword=password" />

Upvotes: 3

Related Questions