I have an EC2 imaging running and hosting a REST service accessible from Url. The following is what I did 1) ssh -i D port user@ec2-host 2) setup proxy in the firefox web browser and type in the url http://ec2-host:port/demo/workflow/lists/demo_workflow
It works fine.
Now I need to send the GET method using Java program, below is my code:
HttpClient client = new HttpClient();
HttpMethod method = new GetMethod("http://ec2-host:port/demo/workflow/lists/demo_workflow");
HostConfiguration config = client.getHostConfiguration();
config.setProxy(proxyHost, port);
client.setHostConfiguration(config);
try {
client.executeMethod(method);
if (method.getStatusCode() == HttpStatus.SC_OK) {
String response = method.getResponseBodyAsString();
System.out.println("Response = " + response);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
method.releaseConnection();
}
But now I run into exceptions below. Any tips? Thanks a lot!
010-08-11 16:46:34,781 INFO [HttpMethodDirector] I/O exception (org.apache.commons.httpclient.NoHttpResponseException) caught when processing request: The server 184.72.46.209 failed to respond 2010-08-11 16:46:34,781 INFO [HttpMethodDirector] Retrying request org.apache.commons.httpclient.NoHttpResponseException: The server [ec2-host] failed to respond at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1976) at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735) at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098) at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398) at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323) at ....[where my code throws exception when invoking client.executeMethod(config)]