atompub, beyond blogs
DESCRIPTION
A presentation by Mohanaraj Gopala Krishnan at barcamp Malaysia 2008. Attribution: Content and inspiration from http://bitworking.org/news/125/REST-and-WS http://bitworking.org/projects/oscon2007/html/TRANSCRIPT
![Page 1: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/1.jpg)
AtomPub, beyond blogs Using the AtomPub protocol as the base of your Web API
![Page 2: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/2.jpg)
Questions for you
• Are you familiar with HTTP (Methods, Status codes etc) ?
• Are you familiar with Web Services/APIs?
• Are you familiar with AtomPub?
• Have you developed a web service before ?
• Have you used/written WS-* ?
• Have used/written AtomPub ?
![Page 3: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/3.jpg)
Your mission - Build a web service that:
![Page 4: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/4.jpg)
• Speaks HTTP, across the Internet
• Is scalable and robust
![Page 5: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/5.jpg)
• Caters to heterogeneous clients (browsers, terminals, other web services )
•Language neutral (Java,PHP,Perl,Python, Ruby and god forbid C , C++ ;))
![Page 6: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/6.jpg)
Options ?(Architecture - wise)
![Page 7: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/7.jpg)
RPC Architecture
• Uses HTTP as a transport protocol - not an application protocol
• Maps procedural programming model to the Web - parameters and method calls are serialized
• Problems already solved by HTTP need to be handled (error handling, caching etc.)
• E.g. XML-RPC and ...
![Page 8: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/8.jpg)
WS - *
"The SOAP stack is generally regarded as an
embarrassing failure these days" Tim Bray
http://www.infoworld.com/article/08/07/24/Sun-technologist-SOAP-stack-a-failure_1.html
![Page 9: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/9.jpg)
RESTful architecture
• HTTP used correctly- application protocol
• Everything has an ID (Link-able)
• Everything is linked to each other
• Fixed interface(GET,PUT,POST,DELETE,HEAD,OPTIONS)
• Multiple representations of a resource
• Stateless
![Page 10: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/10.jpg)
What does using HTTP as an
application protocol give you
for free ?
![Page 11: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/11.jpg)
HTTP Pipelining
Compression (Transport encoding)
Caching (Last-modified, If-modified-since, E-tags,Cache controls)
Content negotiation (mimetype/content type)
Error handling (HTTP status codes)
Simple tooling (curl anybody ?)
Concurrency handling (Optimistic concurrency - If-Match)
Layered approach (Atompub + Opensearch + Digest authentication)
![Page 12: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/12.jpg)
• Atom is both a format and a protocol
• A way to use HTTP correctly
AtomPub is a REST styled protocol (RESTful)
![Page 13: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/13.jpg)
Services using AtomPub
• Google: GData
• Microsoft: Live Platform, Astoria
• IBM: Lotus Connector
• LCA: Resource synchronisation :-)
![Page 14: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/14.jpg)
AtomPub 101
![Page 15: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/15.jpg)
AtomPub 101The data model
![Page 16: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/16.jpg)
Entry
Defines the essential pieces of a document
![Page 17: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/17.jpg)
Essential pieces
• Title
• Author(s)
• ID
• Published Date
• Content
![Page 18: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/18.jpg)
Feed
This is the envelope for entries
![Page 19: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/19.jpg)
Service document
An introspection document for collections
![Page 20: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/20.jpg)
![Page 21: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/21.jpg)
AtomPub 101Operations
![Page 22: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/22.jpg)
Operations on CollectionsMethod Resource Representation Description
GET Collection Atom Feed Retrieve a list of members
POST Collection Atom Entry Add a new member
Operations on MembersMethod Resource Representation Description
GET Member Atom Entry Retrieve a member representation
PUT Member Atom Entry Update a member representation
DELETE Member n/a Delete a member
![Page 23: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/23.jpg)
POST to a collection to create an entry(Request)
![Page 24: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/24.jpg)
POST to a collection to create an entry(Response)
![Page 25: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/25.jpg)
Result
![Page 26: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/26.jpg)
PUT to edit URL to update
![Page 27: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/27.jpg)
GET the entry URL to update
![Page 28: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/28.jpg)
PUT to edit URL to update (Retrieve)
![Page 29: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/29.jpg)
PUT to edit URL to update (Request)
![Page 30: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/30.jpg)
DELETE to edit URL to delete (Request)
![Page 31: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/31.jpg)
When is AtomPub suitable for you ?
![Page 32: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/32.jpg)
Dealing with collections of documents / resources
The collection-item metaphor is a powerful abstraction
Time indexed resources
Sales orders, members, events, filesystem, articles, relationships, transactions
![Page 33: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/33.jpg)
Operations can be mapped to CRUD + List
• Requires some thinking
• Tough when not time indexed
• Something messaging model is better
![Page 34: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/34.jpg)
Heterogeneous & Interop important
"[I]f you don't have control of both ends of the wire then loosely typed documents beat strongly typed data-structure serializations."
http://bitworking.org/news/Nelson_Minar_on_SOAP
![Page 35: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/35.jpg)
http://bitworking.org/news/125/REST-and-WS
Homogenous systems - Serializing objects work OK
Heterogeneous systems - Move towards self descriptive documents
![Page 36: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/36.jpg)
Misconception
Only good for blogs, html/xml type data
![Page 37: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/37.jpg)
Your content in AtomPub
![Page 38: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/38.jpg)
Re-orientate your thinking
• Move from a service orientation to a resource orientation (‘verb to noun’)
• Identify the resources in your system - ‘nouns’
• Map them into collections and entries
• Map the standard interface to the required operations
![Page 39: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/39.jpg)
First identify the entry mandatory fields
![Page 40: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/40.jpg)
![Page 41: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/41.jpg)
In content element
![Page 42: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/42.jpg)
In content element
• Leverage mimetypes -text, html, xhtml
• Use microformats
• Custom XML - Use - application/xml
![Page 43: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/43.jpg)
Extending with custom name space
![Page 44: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/44.jpg)
![Page 45: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/45.jpg)
![Page 46: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/46.jpg)
Use media link entries
![Page 47: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/47.jpg)
Mapping operations
• Google Finance a great example
• Operations mapped
• Managing portfolios
• Managing positions
• Managing transactions
http://code.google.com/apis/finance/developers_guide_protocol.html
![Page 48: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/48.jpg)
What you get ?Standard API
Pagination (RFC 5005)
Discovery (Service document)
Categorization (Atom:category)
Simple sync ( using app:edited )
Test suites for client and servers (Very IMPORTANT! - APE, feedvalidator, JGs apptestclient)
Existing implementations (client and server) that interop (http://intertwingly.net/wiki/pie/InteropGrid)
Existing libraries and toolkits
![Page 49: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/49.jpg)
Limitations ?Multi-depth hierarchies (Possible by such things as rel attrib)
Incremental updates of entries (HTTP Patch, XML Diff)
Multiple(Batch) operations (Being sorted with multipart extension)
Querying (Open search)
Synchronisation (Feed sync , simple system of timestamps)
Long running transactions (Break down the collections)
Collection creation and handling (MetaAtompub)
Authentication / Encryption (Use existing auth schemes)
![Page 50: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/50.jpg)
AtomPub as a layer in the stack
![Page 51: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/51.jpg)
• Consume• curl• httplib2 (any httplib)
• Produce• Amplee (Library) - Python• php-atompub-server - PHP• Abdera(Library) - Java• Catalyst::Controller::Atompub -Perl• mod_atom - C/Apache
Toolkits
![Page 52: AtomPub, beyond blogs](https://reader036.vdocuments.site/reader036/viewer/2022070303/5492a1c2b47959962d8b5511/html5/thumbnails/52.jpg)
[email protected]/blog