调用代码如下:
httpClient = new SSLClient();
httpPost = new HttpPost(url);
httpPost.addHeader("Content-Type", "application/json;charset=utf-8");
httpPost.setHeader("Accept", "application/json");
StringEntity se = new StringEntity(jsonstr, "utf-8");
se.setContentType("text/json");
se.setContentEncoding(new BasicHeader("Content-Type",
"application/json"));
httpPost.setEntity(se);
// 请求超时
httpClient.getParams().setParameter(
CoreConnectionPNames.CONNECTION_TIMEOUT, 10000);
// 读取超时
httpClient.getParams().setParameter(
CoreConnectionPNames.SO_TIMEOUT, 10000);
HttpResponse response = httpClient.execute(httpPost);
if (response != null) {
HttpEntity resEntity = response.getEntity();
if (resEntity != null) {
result = EntityUtils.toString(resEntity, charset);
}
}
返回结果:
双方多次调试没有找到问题,后把调用间隔时间调长,问题不再出现,考虑问题可能是调用太频繁