我想使用httpclient打一个休息服务。但面临问题。这是我的服务器程序。如果我从本地计算机运行此程序,那么它可以很好地服务器并获得响应。 但是当我将这个程序托管到服务器然后点击Rest服务器时,它就会发生异常。我真的无法理解本地和服务器环境之间的区别。
HttpClient httpClient = HttpClientBuilder.create().build();
HttpPost httpPost = new HttpPost();
httpPost.setEntity(se);
HttpResponse resp = null;
String url = "http://gigilitytest.cloud.cms500.com/MMServer/mycircle/saveuserinfo";
URI uri = null;
RequestResult reqResult = new RequestResult();
try {
uri = new URI(url);
httpPost.setURI(uri);
System.out.println("***********************************----------1");
resp = httpClient.execute(httpPost);
System.out.println("***********************************----------2");
System.out.println("resp:" + resp);
Reader reader = new InputStreamReader(resp.getEntity().getContent());
reqResult = gson.fromJson(reader, RequestResult.class);
reader.close();
httpPost.releaseConnection();
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
例外是:
" preferedGenderType":""" imgUrl的":" HTTPS%253A%252F%252Fscontent.xx.fbcdn {{1} }