String response = null;
String url = EspConfig.getClientBaseUrl() + ClientUtil.CLIENT_METHODNAME;
CloseableHttpClient httpclient = HttpClientBuilder.create().build();
HttpPost post = new HttpPost(url);
post.setHeader("Content-Type", "application/json;charset=UTF-8");
StringEntity stringEntity = new StringEntity(JSON.toJSONString(proScheduleVO), "utf-8");
stringEntity.setContentEncoding("utf-8");
stringEntity.setContentType("application/json");
post.setEntity(stringEntity);
try {
HttpResponse res = httpclient.execute(post);
log.info("======"+res.getStatusLine().getStatusCode());
if (res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
response = EntityUtils.toString(res.getEntity());
}
if(response==null){
throw new NullPointerException("推送失败");
}
} catch (Exception e) {
e.printStackTrace();
}
log.info("======"+response);
JSONObject jsonObj = JSON.parseObject(response);
log.info("====="+jsonObj.get("resultCode").toString());