I want to set proxy before sending HttpClient
request on a URL. As I am able to connect it curl command setting up the proxy but with Java code I am not able to
I think this could be helpful:
HttpClient client = new HttpClient();
HostConfiguration config = client.getHostConfiguration();
config.setProxy("someProxyURL", "someProxyPort");
Credentials credentials = new UsernamePasswordCredentials("username", "password");
AuthScope authScope = new AuthScope("someProxyURL", "someProxyPort");
client.getState().setProxyCredentials(authScope, credentials);
EntityEnclosingMethod method = new PostMethod(url);
method.setRequestEntity(new StringRequestEntity(requestXML, "text/xml", "utf-8"));