RestTemplate发送xml类型数据,XML数据存放于Body体中

//设置请求头
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_XML);
StringBuffer xmlString = new StringBuffer();
xmlString.append("")
         .append("");

//请求体
HttpEntity formEntity = new HttpEntity<>(xmlString.toString(), headers);
ResponseEntity responseEntity = restTemplate.postForEntity(url, formEntity, String.class);

你可能感兴趣的:(java)