Announcement Announcement Module
No announcement yet.
RSS and ATOM version support Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • RSS and ATOM version support

    What is the safe way to support the different RSS and ATOM version? In the below sample I have included media types to support. This seems to be working when I provide different RSS or ATOM feeds.

    // Create a new RestTemplate instance
    RestTemplate restTemplate = new RestTemplate();

    // Configure the SyndFeed message converter.
    SyndFeedHttpMessageConverter syndFeedConverter = new SyndFeedHttpMessageConverter();

    List<MediaType> mediaTypes = new ArrayList<MediaType>();

    syndFeedConverter.setSupportedMediaTypes(mediaType s);

    // Add the SyndFeed message converter to the RestTemplate instance
    restTemplate.getMessageConverters().add(syndFeedCo nverter);

    // Initiate the request and return the results
    SyndFeed feed = restTemplate.getForObject(url, SyndFeed.class);

  • #2
    The code you provided is correct usage of the SyndFeedHttpMessageConverter. application/rss+xml, and application/atom+xml are the default media (mime) types associated with this converter. You don't need to set these manually, unless you need to support a different type, as you are doing in your code.