首页 > 解决方案 > 使用“application/xml”标头和字符串 xml 作为正文向 HTTPS 服务 url 发送 POST 请求的最佳方式是什么?

问题描述

这种方式没有奏效。

公共字符串 sendReqest(字符串 httpsUrl,字符串 xmlRequest){

HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_XML);


HttpEntity<String> httpEntity = new HttpEntity<String>(xmlRequest, httpHeaders);

RestTemplate restTemplate = new RestTemplate();
String result = restTemplate.postForObject(httpsUrl, httpEntity, String.class);
return result;

}

我收到此异常: PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径

标签: javaspring-bootposthttps

解决方案


推荐阅读