Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

How to read Atom feed using Spring RestTemplate

 
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
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • 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 Mac OS X IntelliJ IDE Spring Linux
  • 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 Mac OS X IntelliJ IDE Spring Linux
  • 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.
 
Willie Smits can speak 40 languages. This tiny ad can speak only one:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!