public static String HttpPostAnswer(String url, JSONObject jobj) throws ClientProtocolException, IOException, JSONException, HttpException{
AndroidHttpClient client = AndroidHttpClient.newInstance(null);
client.getParams().setParameter(HttpConnectionParams.CONNECTION_TIMEOUT, 7500);
client.getParams().setParameter(HttpConnectionParams.SO_TIMEOUT, 7500);
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new StringEntity(jobj.toString()));
httpPost.setHeader("Accept", "application/json");
httpPost.setHeader("Content-type", "application/json");
HttpResponse response = client.execute(httpPost);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if (statusCode == 200) {
String resp = EntityUtils.toString(response.getEntity());
client.close();
return resp;
} else {
try {
client.close();
}catch (Exception ex){}
throw new HttpException("STATUSCODE!=200");
}
}
ServiceData.java 文件源码
java
阅读 27
收藏 0
点赞 0
评论 0
项目:otrta
作者:
评论列表
文章目录