我通过调用post方法使用Spring3.0 restTemplate使用json Webservice.
I am consuming json webservice using Spring3.0 restTemplate by calling post method.
MultiValueMap<String, String> headers = new LinkedMultiValueMap<String, String>(); headers.add("Content-Type", MediaType.APPLICATION_JSON_VALUE); HttpEntity<Object> entity = new HttpEntity<Object>(requestAsString, headers); postForObject = restTemplate.postForObject(url, entity, responseClass );我们的应用程序已部署在WAS服务器中,并尝试通过使用TLS1.0创建套接字连接来连接生产者.但是,现在生产者仅支持TLS1.1和TLS1.2.
Our application is deployed in WAS server and trying to connect producer by creating socket connection with TLS1.0. However, now producer only supports TLS1.1 and TLS1.2.
如何强制执行restTempate以使用TLS1.1或TLS 1.2.
How to enforce restTempate to use TLS1.1 or TLS 1.2.
通常对于apache httpclient代码,创建自定义ProtocolSocketFactory并覆盖createSocket方法.但是,在RestTemplate的情况下,该如何实现.
Normally for apache httpclient code , create custom ProtocolSocketFactory and override createSocket method. However , in case of RestTemplate , how to achieve same.
推荐答案您可以将RestTemplate配置为使用自定义ClientHttpRequestFactory.特别是(因为您使用的是Spring 3.0),所以有一个 CommonsClientHttpRequestFactory .这样一来,您就可以详细配置通用HTTP,而RestTemplate将使用它来执行其请求.
You can configure your RestTemplate to use a custom ClientHttpRequestFactory. In particular (since you're using Spring 3.0), there is a CommonsClientHttpRequestFactory. That will enable you to configure commons HTTP in detail, and your RestTemplate will use that for executing its requests.
请注意,实际的实现类在Spring的更高版本中已更改(并且如果您仍使用3.0,则应该考虑更新).从3.1开始,实现类称为HttpComponentsClientHttpRequestFactory.
Please note that the actual implementation classes have changed in later versions of Spring (and if you're still on 3.0 you really should consider updating). From 3.1 on the implementation class is called HttpComponentsClientHttpRequestFactory.
更多推荐
如何使用Rest模板将TLS1.2强制为Rest客户端
发布评论