I have a project that's using Camel and running on a ServiceMix server, but I can't seem to get it to access external web services, and I suspect it's because I can't set the proxy authentication properly.
Exchange exchange = producerTemplate.request(url, new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(Exchange.HTTP_METHOD, "POST");
exchange.getIn().setHeader(Exchange.CONTENT_TYPE, "application/json");
}
});
response = exchange.getOut().getBody(String.class);
If I put a breakpoint on the last line, I see a ConnectionTimedOutException in the exchange object and the response is null.
I tried setting the proxies in a multitude of ways.
1) I tried setting the proxy settings in a class that implements CamelContextAware:
camelContext.getProperties().put("http.proxyHost", "...");
camelContext.getProperties().put("http.proxyPort", "8080");
camelContext.getProperties().put("http.proxyUser", "...");
camelContext.getProperties().put("http.proxyPassword", "...");
camelContext.getProperties().put("http.proxySet", "true");
This works in standalone mode, but when I deploy the code in ServiceMix, the camelContext object is null.
2) I tried setting the proxy settings in the etc/system.properties file of ServiceMix.
3) I tried using http-conf:conduit in the camel-context.xml like this:
<http-conf:conduit name="*.http-conduit">
<http-conf:client ProxyServer="..." ProxyServerPort="8080" />
<http-conf:proxyAuthorization>
<conf-sec:UserName>...</conf-sec:UserName>
<conf-sec:Password>...</conf-sec:Password>
</http-conf:proxyAuthorization>
</http-conf:conduit>
However, I think that'd only work if I used a cxf client.
Nothing worked, and I need it to work while deployed on the ServiceMix. Any help would be greatly appreciated.
Thanks.