• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to read Atom feed using Spring RestTemplate

 
Nitesh Patel
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am bit confuse regarding best way to read the ATOM feed using spring "Rest Template". Right now, I am passing the respective url and parameter to and get the response as Source.class. Though I am getting the response correct (same as when I invoke same url in browser) is it right way to read the ATOM feed ?

Below is my spring context configuration for RestTemplate,


Regards,
Nitesh
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I mean it works but why not have a look at org.springframework.http.converter.feed.AtomFeedHttpMessageConverter rather than using the SourceHttpMessageConverter
 
Nitesh Patel
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bin,
Thanks for the reply. Can you please tell me how can I use AtomFeedHttpMessageConverter? Is it only replacing SourceHttpMessageConverter with AtomFeedHttpMessageConverter

What should be my responseType ?

Thanks,
Nitesh
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Response type should be assignable to com.sun.syndication.feed.atom.Feed.

By default it will read and write "application/atom+xml" unless overridden.

Make sure you have Rome on the classpath
 
Nitesh Patel
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bill,

After setting responseType, I will get feed response as com.sun.syndication.feed.atom.Feed, how can I use to convert to other XML form using XSLT. Currently I am using DOMSource as responseType, use java transform mechanism to transform it to other XML format using .xsl file.

Is there any documentation/tutorial available for this ?


Thanks & Regards,
Nitesh
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A quick google search returned this tutorial http://www.ibm.com/developerworks/web/library/wa-restful/ .

I guess I am not exactly sure what your requirements are or why you need to perform any type of transformation on the XML. Depending on the requirements perhaps what you have is the best bet, I was just giving you an alternative for handling ATOM feeds, its hard to say more without knowing more about the context.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic