Since 2003, the Atom format has been used as yet another feed format like RSS, but the Atom protocol opens the door to far more uses of Atom as both a means for distribution and publication. Ben Ramsey introduces the Atom format and protocol, explaining how these can form the foundation of any publishing service and serve as a platform for rich Internet applications.
2. Hi, I’m Ben.
‣ VP of Engineering at Moontoast
‣ Co-founder and organizer emeritus of the Atlanta PHP user group
‣ Current organizer of the Nashville PHP user group
‣ I blog at benramsey.com
‣ I tweet at @ramsey
‣ Please rate this presentation: http://joind.in/2185
Introduction to AtomPub Web Services • Ben Ramsey 2
5. Atom: RFC 4287
Introduction to AtomPub Web Services • Ben Ramsey 5
6. Atom is an XML-based document format that
describes lists of related information known as
“feeds”. Feeds are composed of a number of items,
known as “entries”, each with an extensible set of
attached metadata. For example, each entry has a
title.
The primary use case that Atom addresses is the
syndication of Web content such as weblogs and
news headlines to Web sites as well as directly to
user agents.
—RFC 4287, §1
8. AtomPub: RFC 5023
Introduction to AtomPub Web Services • Ben Ramsey 8
9. The Atom Publishing Protocol is an application-level
protocol for publishing and editing Web Resources using
HTTP and XML 1.0. The protocol supports the creation of
Web Resources and provides facilities for:
Collections: Sets of Resources, which can be retrieved in
whole or in part.
Services: Discovery and description of Collections.
Editing: Creating, editing, and deleting Resources.
The Atom Publishing Protocol is different from many
contemporary protocols in that the server is given wide
latitude in processing requests from clients.
—RFC 5023, §1
11. What about RSS?
Introduction to AtomPub Web Services • Ben Ramsey 11
12. Content Types
‣ RSS allows only for plain text and escaped HTML content types
‣ Atom provides for plain text, escaped HTML, XHTML, XML, and
Base64-encoded binary data
Introduction to AtomPub Web Services • Ben Ramsey 12
13. Internationalization
‣ RSS may have a language set for a feed, but doesn’t have a way to
indicate language for items in the feed
‣ Atom uses the xml:lang attribute to specify language on a per-element
basis
‣ Atom uses IRIs, which allow the usage of characters in identifiers
outside of ASCII
Introduction to AtomPub Web Services • Ben Ramsey 13
14. Modularity
‣ RSS vocabulary elements aren’t reusable in other XML vocabularies
‣ Atom was designed to allow its vocabulary to be mixed with other XML
vocabularies
‣ Namespaces! Atom has one; RSS does not
Introduction to AtomPub Web Services • Ben Ramsey 14
15. Other Things
‣ RSS has no schema; Atom has a RelaxNG schema
‣ RSS defines no mechanism for handling relative URIs; Atom uses
xml:base
‣ Various implementations in RSS leads to interoperability problems
‣ No standard protocol for publishing; RSS is read only
Introduction to AtomPub Web Services • Ben Ramsey 15
17. Profile of Atom
‣ Atom Syndication Format
‣ An XML-based web content and metadata syndication format
‣ Defined by IETF RFC 4287
‣ Fixes the “problems” of RSS
‣ XML namespace: http://www.w3.org/2005/Atom
Introduction to AtomPub Web Services • Ben Ramsey 17
18. Profile of AtomPub
‣ Atom Publishing Protocol or APP
‣ A protocol for publishing and editing web resources using HTTP and
XML
‣ Defined by IETF RFC 5023
‣ Uses Atom as it’s XML syntax
‣ XML namespace: http://www.w3.org/2007/app
Introduction to AtomPub Web Services • Ben Ramsey 18
19. Basics of AtomPub
‣ Each resource has a unique identifier
‣ The resources are well-connected
‣ Resources share the same interface
‣ There is no state; requests are atomic
‣ Follows a resource-oriented architecture
Introduction to AtomPub Web Services • Ben Ramsey 19
30. Methods Cut & Paste
GET Copy
PUT Paste Over
POST Paste After
DELETE Cut
31. Actions for User Resources
‣ Retrieve user collection:
GET /user
‣ Create a new user:
POST /user
‣ Modify an existing user:
PUT /user/ramsey
‣ Delete a user:
DELETE /user/ramsey
Introduction to AtomPub Web Services • Ben Ramsey 31
32. Actions for Content Resources
‣ Retrieve content:
GET /content
‣ Create new content:
POST /content
‣ Modify content:
PUT /content/1234
‣ Remove content:
DELETE /content/1234
Introduction to AtomPub Web Services • Ben Ramsey 32
33. Other Actions
‣ Service discovery:
GET /
‣ Retrieve content for a particular user:
GET /user/ramsey/content
Introduction to AtomPub Web Services • Ben Ramsey 33
34. Let’s see it in action
Introduction to AtomPub Web Services • Ben Ramsey 34
35. GET / HTTP/1.1
Host: atom.example.org
HTTP/1.x 200 OK
Date: Mon, 21 Sep 2009 16:33:45 GMT
Content-Type: application/atomsvc+xml
45. Add Some Content
Introduction to AtomPub Web Services • Ben Ramsey 45
46. First, a Few Notes
‣ You need authentication!
‣ Perhaps you need encryption
‣ You definitely need validation
‣ And I’m not going to tell you how
Introduction to AtomPub Web Services • Ben Ramsey 46
60. AtomPub in PHP
‣ DOM for reading/writing
‣ SimpleXML for reading
‣ XMLReader for reading
‣ XMLWriter for writing
‣ String concatenation for writing
‣ I recommend XMLReader/XMLWriter; they’re the fastest at parsing and
generating XML
Introduction to AtomPub Web Services • Ben Ramsey 60
61. Wrapping Up
‣ You can extend Atom with other XML vocabularies (Dublin Core, etc.)
‣ XML Digital Signature or XML Encryption may be used, or encrypt as a
bag of bits
‣ Use your preferred authentication method
‣ Use HTTP in a RESTful fashion
‣ Use DOM or XMLReader/XMLWriter to parse Atom documents
Introduction to AtomPub Web Services • Ben Ramsey 61
62. Questions?
‣ I blog at benramsey.com
‣ I tweet at @ramsey
‣ Please rate this presentation: http://joind.in/2185
‣ Read the Atom specifications:
RFC 4287
RFC 5023
‣ My company is Moontoast
Introduction to AtomPub Web Services • Ben Ramsey 62
64. Photo Credits
‣ Molecule display, by Christian Guthier
‣ Atom, by jayneandd
‣ Atomium - detail, by Constantin Barbu
‣ Simplicity, by Subterranean Tourist Board
‣ STEREO's Extreme UltraViolet Imager (EUVI), by NASA
‣ Quantum Universe, by Gaurav
‣ Fullerene Nanogears, by NASA
‣ Little Atom, by Marrio
‣ That Atom, by Albert O’Conner
‣ Bokeh Spiral, by Eric Wüstenhagen
‣ Chambered Nautilus Shell - detail, by Jitze Couperus
Introduction to AtomPub Web Services • Ben Ramsey 64