Reputation: 4286
I am trying to consume one of the REST web service from Terremark enterprise cloud. Here is what I have done: 1) Take the xsd and generate jaxb artifacts 2) Send Rest call and let Restclient populate the Organizations class.
ResponseEntity exchange = template.exchange("https://services.enterprisecloud.terremark.com/cloudapi/ecloud/organizations/",
HttpMethod.GET,
new HttpEntity(operation.getInput(), operation.getHeader()),
Organizations.class,
urlVariables);
The error I see is
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]
In the above error, com.dto.Organizations is generated java class by JAXB. Any generic Spring pointers to resolve this issue would also be helpful.
P.S. In spring dispatcher, I have following:
<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>
Upvotes: 0
Views: 970
Reputation: 3120
I believe you are going to need to set the content-type handled by your MarshallingHttpMessageConverter
:
...
<bean id="marshallingHttpMessageConverter"
class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter"
p:marshaller-ref="jaxb2Marshaller" p:unmarshaller-ref="jaxb2Marshaller"
p:supportedMediaTypes="application/vnd.tmrk.cloud.organization"/>
...
...something along those lines. The default supported media type for MarshallingHttpMessageConverter
is simply application/*+xml
.
Upvotes: 1