Title: Building services with AtomPub
1Building services with AtomPub
- An exploration of Atom, AtomPub, REST, and HTTP
2About me
- Open Source Mule, CXF/XFire, Abdera, Apache-
- Exploring how to make building distributed
services more powerful/approachable/scalable/etc - MuleSource
3Topic Map
4The model and the protocol
5Atom Roots
- Atom was created out of frustration with the RSS
format - Many inconsistencies, many different versions
- Syndication format
- Blogs
- Monitoring
- Search
- Directories
- Etc
- IETF RFC 4287
6Atom Feed Structure (roughly)
- Feed
- ID
- Author
- Link
- Title
- Updated
-
- Entry
- ID
- Updated
- Link
- Summary
- Content
7The Bare Minimum Atom Feed
-
-
- Dans Blog
-
- 2007-11-07T183002Z
-
- Dan Diephouse
-
- urnuuid60a76c80-d399-11d9-b91C-0003939e0af6
-
- Building services with AtomPub
- rvices"/
- urnuuid1225c695-cfb8-4ebb-aaaa-80da344efa
6a - 2007-11-07T183002Z
-
- (you must have content or a summary)
-
8Atom Publishing Protocol Model
9APP Model Services Workspaces
- xmlnsatom"http//www.w3.org/2005/Atom"
-
- Dans Website
-
- href"http//netzooid.com/blog/feed"
- Dans Blog
-
-
- href"http//netzooid.com/pics"
- Dans Pictures
- image/png
- image/jpeg
- image/gif
-
-
10What is the Atom Publishing Protocol?
- Create, edit, delete resources
- Extensible Protocol
- Authentication extensions (i.e. WSSE)
- Opensearch
- GData
- Properly uses HTTP so it can be scalable and
reliable - Builds on Atom model
11AtomPub Resources
12GET /
- xmlnsatom"http//www.w3.org/2005/Atom"
-
- Dans Website
-
- href"http//netzooid.com/blog/feed"
- Dans Blog
-
-
- href"http//netzooid.com/pics"
- Dans Pictures
- image/png
- image/jpeg
- image/gif
-
-
13GET /
- xmlnsatom"http//www.w3.org/2005/Atom"
-
- Dans Website
-
- href"http//netzooid.com/blog/feed"
- Dans Blog
-
-
- href"http//netzooid.com/pics"
- Dans Pictures
- image/png
- image/jpeg
- image/gif
-
-
14GET /blog/feed
-
-
- Dans Blog
-
- 2007-12-13T183002Z
-
- Dan Diephouse
-
- urnuuid60a76c80-d399-11d9-b91C-0003939e0af6
-
- Building services with AtomPub
- es"/
- es
- rel"edit"/
- urnuuid1225c695-cfb8-4ebb-aaaa-80da344efa
6a - 2007-12-13T183002Z
-
15A note on
- Entries contain a set of links
- Each link has a relationship attribute
- No rel attribute means its an alternate
representation i.e. HTML
16GET /blog/feed/app_services.atom
-
- Building services with AtomPub
- s"/
- rvices.atom
- reledit /
- urnuuid1225c695-cfb8-4ebb-aaaa-80da344efa6
a - 2007-12-13T183002Z
-
-
-
-
17POST /blog/feed (request)
-
- Atom Pub Patterns
- urnuuid1225c695-cfb8-4ebb-aaaa-xxxxxxxxxxx
x - 2007-11-07T183002Z
-
- There are many ways to integrate with Atom
services -
-
18POST /blog/feed (response)
- Location http//netzooid.com/blog/feed/patterns.a
tom -
- Atom Pub Patterns
- urnuuid1225c695-cfb8-4ebb-aaaa-xxxxxxxxxxx
x - 2007-11-07T183002Z
-
- ns.atom
- reledit /
-
- There are many ways to integrate with Atom
services -
-
19GET /blog/feed/patterns.atom
-
- Atom Pub Patterns
- urnuuid1225c695-cfb8-4ebb-aaaa-xxxxxxxxxxx
x - 2007-11-07T183002Z
-
- ns.atom
- reledit /
-
- There are many ways to integrate with Atom
services -
20PUT /blog/feed/patterns (request)
-
- Atom Pub Patterns
- urnuuid1225c695-cfb8-4ebb-aaaa-xxxxxxxxxxx
x - 2007-11-08T183002Z
-
- AtomPub can be used in a variety of
integration - scenarios.
-
21DELETE /blog/feed/patterns
22ETag Example
Client
Server
- HTTP/1.1 200 OK
- Date
- ETag "3e86-410-3596fbbc"
- Content-Length 1040
- Content-Type text/html
- GET /blog/feed
- Host netzooid.com
Server
Client
HTTP/1.1 304 Not Modified Date ETag
"3e86-410-3596fbbc" Content-Length 0
- GET /blog/feed
- If-None-Match
- "3e86-410-3596fbbc"
- Host netzooid.com
23Media Resources and Media Link Entries
- What about data which you dont want to
necessarily redistribute all the time? - i.e. its too large
- What about non-XML data?
- Images
- APP defines
- Media Resource your data
- Media Link Entry An atom entry which describes
your data
24Media Resources
25Service
- xmlnsatom"http//www.w3.org/2005/Atom"
-
- Dans Website
-
- href"http//netzooid.com/blog/feed"
- Dans Blog
-
-
- href"http//netzooid.com/pics"
- Dans Pictures
- image/png
- image/jpeg
- image/gif
-
-
26POST /pics/ (request)
- Content-Type image/png
- Slug Dan Rambles
- binary data
27POST /pics/ (request)
-
- Dan rambles
- urnuuid1225c695-cfb8-4ebb-aaaa-80da344efe6
b - 2007-11-07T172643Z
-
- Dan Diephouse
-
-
-
- src"http//netzooid.com/pics/dan_rambles.png"
/ -
- href"http//netzooid.com/pics/dan_rambles.png"
/ -
- href"hhttp//netzooid.com/pics/dan_rambles.ato
m" /
28The Media Link Entry
- You can add summary later or have it
auto-generated from the content. - Allows you to store, browse, updated, delete
anything! - Pictures
- XML documents
- Jars
- Videos
- Messages
29Why oh why?
30Universal
- Atom is widely understood
- Provides ubiquitous elements which have meaning
across all contexts - Summary/Content
- Updated date
- ID
- Links
- Clients do not need to understand your specific
application to interact with it
31Leverage HTTP
- AtomPub (nearly) guarantees youll follow RESTful
best practices and have a scalable service - Uniform Interface
- ETags
- Caching
- Reliability
- Avoid writing your own protocol
32Existing Infrastructure
- Many Atom/AtomPub libraries/frameworks are
popping up - Abdera (Java)
- Propono (Java)
- Amplee (Python)
- You dont need a framework though Just use HTTP
- wget
- commons httpclient
- etc
33Building Services Patterns and Strategies
- Some scientists claim that hydrogen, because it
is so plentiful, is the basic building block of
the universe. I dispute that. I say that there is
more stupidity than hydrogen, and that is the
basic building block of the universe. - Frank Zappa
34Microcontent
- Embed your own extensions inside Atom entries
- Extensions become your model
- Examples
- Contacts
- Calendars
- Event Monitoring
- Purchase Orders
- Anything
35GET /contacts
-
- Contacts
-
- 2007-12-13T183002Z
-
- Contact Manager
-
- urnuuid60a76c80-d399-11d9-b91C-0003939e0af6
-
- Dan Diephouse
- phouse
- rel"edit"/
- urnuuid1225c695-cfb8-4ebb-aaaa-80da344efa
6a - 2007-12-13T183002Z
-
- Dan Diephouse
1 555.555.5555 -
36GET /contacts
-
- Contacts
-
- 2007-12-13T183002Z
-
- Contact Manager
-
- urnuuid60a76c80-d399-11d9-b91C-0003939e0af6
-
- Dan Diephouse
- phouse
- rel"edit"/
- urnuuid1225c695-cfb8-4ebb-aaaa-80da344efa
6a - 2007-12-13T183002Z
-
- Dan Diephouse
1 555.555.5555 -
37PUT /contacts/dan_diephouse
-
- Dan Dipehouse
- urnuuid1225c695-cfb8-4ebb-aaaa-80da344efa6
a - 2007-12-13T183002Z
-
-
- name"Dan Diephouse"
- phone"10000000000"
- city"Grand Rapids"
38Microformat
-
- Contacts
-
- 2007-12-13T183002Z
-
- Contact Manager
-
- urnuuid60a76c80-d399-11d9-b91C-0003939e0af6
-
- Dan Diephouse
- phouse
- rel"edit"/
- urnuuid1225c695-cfb8-4ebb-aaaa-80da344efa
6a - 2007-12-13T183002Z
-
- Dan Diephouse
- 1 555 555 5555
39Microcontent
- Microcontent can be anything to do with your
application - Summary, date, link, id can provide information
which is understandable by everyone - Atom servers preserve all metadata not
specifically updated - Media entries may be more suitable for some
applications even if you are using XML content - Becomes searchable with things like OpenSearch
GData
40OpenSearch
- An XML format for describing how to query
resources - Like WSDL for search
41Example
- /opensearch/1.1/"
- Contact Search
- Search the contact
database. - example web
- admin_at_example.com
-
- type"application/atomxml"
- template"http//example.com/?qsearchTerms
amppwstartPage?" /
42OpenSearch
- Offers a way to tell people how to search your
service - Several standard parameters
- searchTerms Search criteria
- count The number of results per page
- startPage The page of results
- language The language of the results
- etc..
- Define your own terms as well
43Example
-
- xmlnsopensearch"http//a9.com/-/spec/opensearc
h/1.1/" -
-
- rel"search"
- href"http//example.com/opensearchdescription
.xml" - type"application/opensearchdescriptionxml"
- title"Content Search" /
-
44GET /feed?qDanpw0
-
- ...
- 35ults
- 1
- 10Page
- searchTerms"Dan" startPage"1" /
- type"text/html"/
- type"application/atomxml"/
- type"application/atomxml"/
- type"application/atomxml"/
- type"application/atomxml"/
- escriptionxml"
- href"http//example.com/opensearchdescrip
tion.xml"/ -
-
- ...
- phone"15555555555"
45What is GData?
- simple standard protocol for reading and writing
data on the web
46What does that mean?
- Standard way to query feeds
- Specifies optimistic concurrency model
- Way to authenticate users
- Common elements for Google services
- A way to do batch operations
- All built on AtomPub
- Used for all Googles APIs
47Batch
- APP doesnt specify a way to do batch operations
- GData supplies one way, but it has received a
cold reception as a general purpose way to do
batch things - Some things to think about
- How do you deal with errors?
- Does your batch method lose the benefits of the
uniform interface?
48GData Batch
-
-
-
- ... what to insert ...
-
-
-
- ... what to update ...
-
-
-
- ... what to delete ...
-
-
-
- ... what to query ...
-
49GData Batch response
50Thoughts on GData
- Weakness in APP?
- Or strength because its extensible?
51Hierarchies
- How do I model collections of collections/trees/hi
erarchies? - Example
1 N
1 N
52Hierarchical data with Atom
-
- Customer Acme Inc.
- urnuuid1225c695-cfb8-4ebb-aaaa-xxxxxxxxxxx
x - 2007-11-07T183002Z
- Acme Inc.
-
- href"http//example.com/customers/purchaseOrd
ers" - Purchase Orders
-
53Hierarchical data with Atom
-
- Customer Acme Inc.
- urnuuid1225c695-cfb8-4ebb-aaaa-xxxxxxxxxxx
x - 2007-11-07T183002Z
- Acme Inc.
-
- href"http//example.com/customers/purchaseOrd
ers" - rel"purchase-orders"
- Purchase Orders
-
-
- href"http//example.com/customers/contacts"
- rel"contacts"
- Contacts
-
54Thoughts on Hierarchies
- It works!
- But is ugly Clients do not inherently understand
hierarchies - Multiple collections require rel attribute,
which makes the relationships even less clear
55Eventing
- Publish and consume entries which map to events
- Application level events
- Exceptions/fault monitoring
- Business level events
- A expense over 1000 was registered
- Use query parameters to narrow down the criteria
- Works with any client which understands Atom
- Powerful combination with opensearch
56Security
- Goals?
- Privacy, Integrity, authentication, authorization
- SSL
- HTTP Auth
- WSSE
- Google Auth
- XML Signature Encryption
57Why not?
58Why not AtomPub?
- More appropriately when not
- Data is not time indexed
- Universality does not yield any benefits
- Batch
- Performance
- Messaging may be a more appropriate model
- Hierarchy kinda sucks
- Transactions
59Contrasts and Comparisons
- A possibly pointless comparison to WS-
60Comparing to WS- scaling
- Builds on HTTPs scalability
- Stateless
- ETags
- Caching
- No inherent caching/etags
- Can be stateless or stateful
- A message oriented approach which may be more
suited to some applications - (there is also Atom over XMPP)
61Comparisons feature applicability
- Constraints in format bring universality, but
also limit use cases - Covers many of the security, reliability use
cases - Requires dev to know HTTP ins and outs
- Provides useful things like
- Message ordering
- WS-Trust
- WS-Policy
- Of course it also provides things like
- WSDL
- Interop problems
- Complexity
62Comparisons interoperability
- Atom format is widely understood
- Avoids interop problems by not trying to support
everything WS- supports - Proprietary extensions are still liable to have
interop problems just like WS-
- Core (SOAP/WSDL/Schema) is highly interoperable
now - WS- is interoperable to various degrees, mainly
on Java/.NET
63Comparisons developers
- Currently a pain to muck with many HTTP libraries
and Atom parsers - Improving with future releases of APP frameworks
- Simple and understandable
- Can write a .NET/Java interop application within
a couple minutes - Must understand WSDL, XML-Schema, SOAP, WS-I BP,
etc, etc
64The one true protocol?
- No, but
- AtomPub can be applied to a wide variety of
business applications - Universality can be powerful
- Hypertext model is powerful
- AtomPub is a great example of how to build a
RESTful protocol
65Questions?
- Blog http//netzooid.com/blog
- Email dan.d_at_mulesource.com
- Some stuff Ive been working on
- http//incubator.apache.org/abdera
- http//www.mulesource.org/display/ABDERA