public RmiRespBase sendHttpRes(String jsonParamStr, String url, String apiName,String systemId,String apiUrl) {
sendLog(apiName,url + apiUrl,jsonParamStr,null); //自定义日志方法       //设置请求头headers
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
    //将headers和参数 json放入entity对象中
HttpEntity<String> entity = new HttpEntity<>(jsonParamStr, headers); //设置连接超时时间
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
requestFactory.setConnectTimeout(Integer.valueOf(timeoutvalue));
requestFactory.setReadTimeout(Integer.valueOf(timeoutvalue));
      //创建远程调用api,并构造连接超时的设置
restTemplate = new RestTemplate(requestFactory);
      //调用,并返回
JSONObject body = restTemplate.postForEntity(url + apiUrl, entity, JSONObject.class).getBody();       //自定义逻辑,返回结果
RmiRespBase respBase = new RmiRespBase(url + apiUrl, apiName, systemId, body);
sendLog(apiName,url + apiUrl,jsonParamStr,body.toJSONString()); //自定义日志方法
return respBase;
}
/**
* 描述:
* 基础Http调用
* @Param [jsonParamStr, url, apiName, systemId, apiUrl]
**/
public RmiRespBase sendHttpRes(String jsonParamStr, String url, String apiName,String systemId,String apiUrl) {
sendLog(apiName,url + apiUrl,jsonParamStr,null);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
HttpEntity<String> entity = new HttpEntity<>(jsonParamStr, headers); //设置连接超时时间
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
requestFactory.setConnectTimeout(Integer.valueOf(timeoutvalue));
requestFactory.setReadTimeout(Integer.valueOf(timeoutvalue));
restTemplate = new RestTemplate(requestFactory); JSONObject body = restTemplate.postForEntity(url + apiUrl, entity, JSONObject.class).getBody();
RmiRespBase respBase = new RmiRespBase(url + apiUrl, apiName, systemId, body);
sendLog(apiName,url + apiUrl,jsonParamStr,body.toJSONString());
return respBase;
}

最新文章

  1. [转]struts1.2的action参数配置
  2. Q114第一颗二叉查找树(链式)
  3. 通过rinetd实现端口转发来访问内网的服务
  4. cocos2dx游戏开发——微信打飞机学习笔记(七)——Enemy的搭建
  5. [ZZ] 基于DirectX shader的Per-pixel lighting实现
  6. VB6 GDI+ 入门教程[6] 图片
  7. MS SQL Server 如何得到执行最耗时的前N条T-SQL语句-
  8. MPEG-DASH on IIS Practice in Action
  9. ES6的转换器
  10. Linux分区和挂载(mount命令的学习)
  11. 关闭默认共享,禁止ipc$空连接
  12. python全栈开发day117-MongoDB,pymongo
  13. Python爬取地图瓦片
  14. oracle报错ORA-01653 dba_free_space中没有该表空间
  15. 廖雪峰Java7处理日期和时间-3java.time的API-2ZonedDateTime
  16. JavaScript基本操作之——九个 Console 命令
  17. (原创)c++中的类型擦除
  18. xml Schema include
  19. Codeforces.643E.Bear and Destroying Subtrees(DP 期望)
  20. 互评Alpha作品——Hello World!团队作品空天猎

热门文章

  1. mysql用户管理和pymysql
  2. Print Article /// 斜率优化DP oj26302
  3. 由Toolbar造成的ListView最后一项显示不全
  4. 大型SQL文件导入mysql方案
  5. 2019-7-1-Roslyn-让编译时候-Message-内容默认输出
  6. JS规则 确定你的存在(变量声明) 声明变量语法: var 变量名; 一次声明多个,中间用逗号隔开var num1,mun2 ;
  7. centos 7 开机优化shell
  8. gnome3 修改桌面背景图片模式
  9. ElasticSearch _bulk批量处理报错The bulk request must be terminated by a newline
  10. 菜鸟安装 CocoaPods