1.使用HttpEntity调用三方接口,通常配合restTempLate一起使用
RestTemplate restTemplate = new RestTemplate();
//请求头
HttpHeaders headers = new HttpHeaders();
//添加请求头信息
headers.add("","");
//可设置请求体类型,默认为ALL
//根据三方接口自行填充请求体参数
headers.setContentType();
//第一个参数:body,第二个参数:headers
HttpEntity<String> entity = new HttpEntity<>("HelloWorld", headers);
//第一个参数:请求地址,第二个参数:一个HTTP请求
URI location = restTemplate.postForLocation("http://localhost:8080", entity);
//获取请求结果集
ResponseEntity<String> result=restTemplate.exchange(url,HttpMethod.POST,entity,String.class);