Announcement Announcement Module
Collapse
No announcement yet.
SimpleXmlHttpMessageConverter with HTML in Android Spring Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SimpleXmlHttpMessageConverter with HTML in Android Spring

    Using Android Spring with SimpleXmlHttpMessageConverter, I would like to be able to deserialize the default html document returning a directory listing from my web server. I've constructed the corresponding java class objects and annotations but the SimpleXmlHttpMessageConverter is rejecting the deserialization based on the fact that the content type is text/html. The server DOES return the context type as text/html, but the html in this case is valid xml, so shouldn't I be able to deserialize it? How can I tell SimpleXmlHttpMessageConverter to do so?

  • #2
    You can try to set the supported media types of the SimpleXmlHttpMessageConverter so that RestTemplate will identify it as capable of handling the response.

    Code:
    SimpleXmlHttpMessageConverter converter = new SimpleXmlHttpMessageConverter();
    converter.setSupportedMediaTypes(Collections.singletonList(MediaType.TEXT_HTML));
    restTemplate.getMessageConverters().add(converter);

    Comment

    Working...
    X