I'm using ROME for RSS feed generating and Jersey as REST service.
Here is my RSS feed generation.
public SyndFeed generate()
{
SyndFeed feed = new SyndFeedImpl();
feed.setFeedType( "rss_2.0" );
feed.setTitle( "My Site" );
feed.setLink("http://example.com");
feed.setDescription("Test Site.");
List<SyndEntry> entries = new ArrayList<SyndEntry>();
SyndEntry entry = null;
SyndContent description = null;
entry = new SyndEntryImpl();
entry.setTitle( "Entry1" );
entry.setLink( "http://example.com/entry1" );
entry.setPublishedDate( new Date() );
description = new SyndContentImpl();
description.setType("text/html");
description.setValue( "This is the content of entry 1." );
entry.setDescription( description );
entries.add( entry );
feed.setEntries(entries);
return feed;
}
And method of getting the feed
@GET
@Path("/getFeed")
@Produces(MediaType.APPLICATION_XML)
public SyndFeed getFeed()
{
RSSFeed rssFeed = new RSSFeed ();
return rssFeed.generate();
}
I'm getting an error for incompatible type for body writer. How could make service to return XML with the feed?
Jersey does not know how to map an instance of
SyndFeed
to XML. This works.GET
the resource: