我正在尝试使用Terremark企业云的一个REST Web服务。以下是我所做的:1)获取xsd并生成jaxb工件2)发送Rest调用并让Restclient填充Organizations类。
ResponseEntity exchange = template.exchange("https://services.enterprisecloud.terremark.com/cloudapi/ecloud/organizations/",
HttpMethod.GET,
new HttpEntity(operation.getInput(), operation.getHeader()),
Organizations.class,
urlVariables);
我看到的错误是
org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [com.dto.Organizations] and content type [application/vnd.tmrk.cloud.organization;type=collection]
在上面的错误中,com.dto.Organizations是由JAXB生成的java类。任何通用的Spring指针来解决这个问题也是有帮助的。
P.S.在 Spring 调度员中,我有以下内容:
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
<property name="messageConverters">
<list>
<bean id="marshallingHttpMessageConverter"
class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter"
p:marshaller-ref="jaxb2Marshaller" p:unmarshaller-ref="jaxb2Marshaller" />
<bean class="org.springframework.http.converter.StringHttpMessageConverter"/>
<bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"/>
<bean class="org.springframework.http.converter.ResourceHttpMessageConverter"/>
</list>
</property>
</bean>
1条答案
按热度按时间mftmpeh81#
我相信你需要设置
MarshallingHttpMessageConverter
处理的内容类型:......沿着的东西。
MarshallingHttpMessageConverter
默认支持的媒体类型仅为application/*+xml
。