我正在使用atom / xml,我需要将其转换为java对象。 代码如下,我遇到转换错误
代码:
ResponseEntity<BusinessPartner> response = restTemplate.exchange(url + "/BP_HEADERSet('100000010')", HttpMethod.GET, entity, BusinessPartner.class);
错误:
"message": "Could not extract response: no suitable HttpMessageConverter found for response type [class com.leaseplan.insuranceaccounting.models.BusinessPartner] and content type [application/atom+xml;charset=utf-8;type=entry]",
BusinessPartner
是我的自定义类。从网址中,我得到的响应是原子格式<content type="application/xml">
答案 0 :(得分:0)
您可以尝试将AtomFeedHttpMessageConverter
和RssChannelHttpMessageConverter
添加到休息模板。
看一下代码:
@Bean
public RestTemplate restTemplate(RestTemplateBuilder templateBuilder) {
return templateBuilder
.additionalMessageConverters(
new AtomFeedHttpMessageConverter(),
new RssChannelHttpMessageConverter())
.build();
}