Hi all,
I am using the following code to make a http client ,i am facing problem in execute method ,its getting stuck there.
public static final HttpHost target = new HttpHost("test.xyz.com", 443, "https");
public static void test()
{
HttpEntity responseEntity = null;
DefaultHttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("/xyz/test");
System.out.println("post is " +post.getRequestLine());
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password);
AuthScope authScope = new AuthScope(target.getHostName(), target.getPort());
System.out.println("auth scope is " +authScope);
client.getCredentialsProvider().setCredentials(authScope, credentials);
//i am passing a xml here
post.setEntity(new StringEntity(xml, "UTF-8"));
post.addHeader("Content-Type", "application/xml");
post.addHeader("Accept", "application/xml");
System.out.println("post " +post.getAllHeaders().length);
HttpResponse response = client.execute(target, post); //getting stuck here no response at all
System.out.println("response " +response.getStatusLine());
responseEntity = response.getEntity();
System.out.println("response entity " +responseEntity);
String responseXmlString = EntityUtils.toString(responseEntity);
System.out.println("response" +responseXmlString);
}
i am facing problem here
HttpResponse response = client.execute(target, post);
what might be wrong ?
The problem is the code is getting stuck in client.execut method its not moving furthur neither i am getting any response.Do i have to set any proxy?