HttpClient is not passing through proxy
Am trying to consume a web service which is running on different sub-domain but on the same domain. I am getting java.net.ConnectException: Connection timed out. Below is code which I am using to call the webservice from OSGI Component class.
String url = "https://banking.pnc.com";
PostMethod post = null;
BufferedReader br = null;
try {
HttpClient httpClient = new HttpClient();
post = new PostMethod(url);
post.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
String json_Params = "{\"token\":\"" + token \"}";
StringRequestEntity requestEntity = new StringRequestEntity(json_Params, "application/json", "UTF-8");
post.setRequestEntity(requestEntity);
int statusCode = httpClient.executeMethod(post);
logger.debug("statusCode :::"+statusCode);
response.setStatus(statusCode);
} catch (Exception e) {
logger.error("Error while ", e);
} finally {
}
Configured the proxy settings in OSGI Config "Day Commons HTTP Client 3.1", This request is not passing through the proxy , because of this am getting Connection timed out. Added the following proxy configuration to the HttpClient in the code and this is working good, it is passing thru proxy server.
// HostConfiguration config = httpClient.getHostConfiguration();
// config.setProxy(HTTP_Proxy_URL,Http_Proxy_port);
// int statusCode = httpClient.executeMethod(config, post);
if we configure the proxy settings in OSGI Config "Day Commons HTTP Client 3.1", will HttpClient instance automatically picks proxy settings? or we need to pass the proxy settings in the code as shown above?