@Autowired
RestTemplate restTemplate;
@PostConstruct
public void init() {
logger.info("---------------加载电子身份证服务接口配置---------------");
SimpleClientHttpRequestFactory simpleClientHttpRequestFactory = new SimpleClientHttpRequestFactory();
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("172.16.18.10", 9000));//配置代理服务器
simpleClientHttpRequestFactory.setProxy(proxy);
restTemplate = new RestTemplate(simpleClientHttpRequestFactory);
}
public Object call(String url, Map param){
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
param.put("username",username);
param.put("token",token);
String requestBody = JSON.toJSONString(param);
logger.info("三门峡接口url:{},入参:{}",url,requestBody);
HttpEntity httpEntity = new HttpEntity(requestBody, httpHeaders);
String r = restTemplate.postForObject(url, httpEntity, String.class);
JSONObject jsonObject = JSONObject.parseObject(r);
logger.info("三门峡接口url:{},返回结果:{}",url,jsonObject);
return jsonObject;
}