File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes How to read Atom feed using Spring RestTemplate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "How to read Atom feed using Spring RestTemplate" Watch "How to read Atom feed using Spring RestTemplate" New topic
Author

How to read Atom feed using Spring RestTemplate

Nitesh Patel
Ranch Hand

Joined: Mar 16, 2008
Posts: 33
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

Joined: Mar 07, 2010
Posts: 1648
    
    7

Well I mean it works but why not have a look at org.springframework.http.converter.feed.AtomFeedHttpMessageConverter rather than using the SourceHttpMessageConverter


[How To Ask Questions][Read before you PM me]
Nitesh Patel
Ranch Hand

Joined: Mar 16, 2008
Posts: 33
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

Joined: Mar 07, 2010
Posts: 1648
    
    7

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

Joined: Mar 16, 2008
Posts: 33
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

Joined: Mar 07, 2010
Posts: 1648
    
    7

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to read Atom feed using Spring RestTemplate