httpClient调用post接口返回html页面

调用代码如下:

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);

}

}

返回结果:

返回的html不是对方接口项目的页面

双方多次调试没有找到问题,后把调用间隔时间调长,问题不再出现,考虑问题可能是调用太频繁

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容