Internet Explorer 6 is having a problem with displaying atom feed documents which's mime type is "application/atom+xml". The browser attempts to download the file instead of rendering it. Simply this happens because browser does not accept or recognize the mime type.
A simple hack can be done to avoid this issue from the server side. That is changing the mime type to appication/xml or text/plain, only if the user agent is IE6 in the HTTP header. Changing the mime type will not fix the problem but at least the browser will display the raw XML content.
The back end application or the server can be configured to send the correct mime type to the relevant browser by looking at the User-Agent header in the HTTP request.
This blog mainly contains technical stuff. It may contain info of some events too.
Showing posts with label atom. Show all posts
Showing posts with label atom. Show all posts
Wednesday, January 28, 2009
Monday, September 22, 2008
Writing a Simple Atompub Client Using Apache Abdera
The atom publishing protocol (similar to RSS but with an enhanced ability) is an application level protocol for editing and publishing web resources for periodically updated web sites, using HTTP. An atom document which adheres to the Atom syndication format spec, is used as an atom feed or entry.
Apache Abdera implements this protocol and exposes a simple API to make the thing easy. The way to create an atom feed and to add an entry is shown below.
Apache Abdera implements this protocol and exposes a simple API to make the thing easy. The way to create an atom feed and to add an entry is shown below.
Abdera abdera = new Abdera();
Feed fd = abdera.newFeed();
fd.setId("unique feed id");
fd.setTitle("feed title");
fd.setUpdated(new Date());
fd.addAuthor("username");
//adding the entry
Entry entry = fd.addEntry();
entry.setId("unique id");
entry.setTitle("entry title");
entry.setSummary("summary");
entry.setContent("The content goes here");
entry.addSimpleExtension(new QName(namespace, "elementName"), "elementContent");//To add an extra element to the entry
entry.setUpdated(new Date());
Now let's see how to post this feed to the abdera server which contains all business logic.AbderaClient client = new AbderaClient(abdera);
ClientResponse response = client.post("http://www.somesite.com/collection",fd);
Retrieving feeds is just a matter of calling Abdera client's get method.ClientResponse response = client.get("http://www.somesite.com/collection/atom1.php");
Document doc = response.getDocument();
Abdera client can call put, delete methods as well. Meanwhile the server side should implement the relevant business logic for these methods.This is a good tutorial with further information to follow.
Subscribe to:
Posts (Atom)