代码中通过restTemplate调用接口
private String sendHttpPost4Rest(String jsonStr) {
String author = "Basic "
+ Base64.getEncoder().encodeToString((this.userName + ":" + this.password).getBytes()).trim();
HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.AUTHORIZATION, author);
headers.add(HttpHeaders.CONTENT_TYPE, "application/json;charset=utf-8");
headers.add(HttpHeaders.ACCEPT, "application/json");
HttpEntity<String> formEntity = new HttpEntity<>(jsonStr, headers);
String message = jsonStr.replaceAll(Constants.WRAP, Constants.BLANK);
logger.info(SEND_MESSAGE, message);
RestTemplate restTemplate = new RestTemplate();
return restTemplate.postForObject(this.url, formEntity, String.class);
}