Building services with AtomPub - PowerPoint PPT Presentation

1 / 65
About This Presentation
Title:

Building services with AtomPub

Description:

href='http://netzooid.com/pics' atom:title Dan's Pictures /atom:title ... POST /pics/ (request) entry xmlns='http://www.w3.org/2005/Atom' title Dan ... – PowerPoint PPT presentation

Number of Views:139
Avg rating:3.0/5.0
Slides: 66
Provided by: DAN390
Category:

less

Transcript and Presenter's Notes

Title: Building services with AtomPub


1
Building services with AtomPub
  • An exploration of Atom, AtomPub, REST, and HTTP

2
About me
  • Open Source Mule, CXF/XFire, Abdera, Apache-
  • Exploring how to make building distributed
    services more powerful/approachable/scalable/etc
  • MuleSource

3
Topic Map
4
The model and the protocol
5
Atom 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

6
Atom Feed Structure (roughly)
  • Feed
  • ID
  • Author
  • Link
  • Title
  • Updated
  • Entry
  • ID
  • Updated
  • Link
  • Summary
  • Content

7
The 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)

8
Atom Publishing Protocol Model
9
APP 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

10
What 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

11
AtomPub Resources
  • Description

12
GET /
  • 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

13
GET /
  • 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

14
GET /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

15
A 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

16
GET /blog/feed/app_services.atom
  • Building services with AtomPub
  • s"/
  • rvices.atom
  • reledit /
  • urnuuid1225c695-cfb8-4ebb-aaaa-80da344efa6
    a
  • 2007-12-13T183002Z

17
POST /blog/feed (request)
  • Atom Pub Patterns
  • urnuuid1225c695-cfb8-4ebb-aaaa-xxxxxxxxxxx
    x
  • 2007-11-07T183002Z
  • There are many ways to integrate with Atom
    services

18
POST /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

19
GET /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

20
PUT /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.

21
DELETE /blog/feed/patterns
  • 200 OK

22
ETag 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

23
Media 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

24
Media Resources
  • Description

25
Service
  • 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

26
POST /pics/ (request)
  • Content-Type image/png
  • Slug Dan Rambles
  • binary data

27
POST /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" /

28
The 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

29
Why oh why?
30
Universal
  • 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

31
Leverage HTTP
  • AtomPub (nearly) guarantees youll follow RESTful
    best practices and have a scalable service
  • Uniform Interface
  • ETags
  • Caching
  • Reliability
  • Avoid writing your own protocol

32
Existing 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

33
Building 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

34
Microcontent
  • Embed your own extensions inside Atom entries
  • Extensions become your model
  • Examples
  • Contacts
  • Calendars
  • Event Monitoring
  • Purchase Orders
  • Anything

35
GET /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

36
GET /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

37
PUT /contacts/dan_diephouse
  • Dan Dipehouse
  • urnuuid1225c695-cfb8-4ebb-aaaa-80da344efa6
    a
  • 2007-12-13T183002Z
  • name"Dan Diephouse"
  • phone"10000000000"
  • city"Grand Rapids"

38
Microformat
  • 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

39
Microcontent
  • 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

40
OpenSearch
  • An XML format for describing how to query
    resources
  • Like WSDL for search

41
Example
  • /opensearch/1.1/"
  • Contact Search
  • Search the contact
    database.
  • example web
  • admin_at_example.com
  • type"application/atomxml"
  • template"http//example.com/?qsearchTerms
    amppwstartPage?" /

42
OpenSearch
  • 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

43
Example
  • xmlnsopensearch"http//a9.com/-/spec/opensearc
    h/1.1/"
  • rel"search"
  • href"http//example.com/opensearchdescription
    .xml"
  • type"application/opensearchdescriptionxml"
  • title"Content Search" /

44
GET /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"

45
What is GData?
  • simple standard protocol for reading and writing
    data on the web

46
What 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

47
Batch
  • 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?

48
GData Batch
  • ... what to insert ...
  • ... what to update ...
  • ... what to delete ...
  • ... what to query ...

49
GData Batch response
  • ...
  • itemB

50
Thoughts on GData
  • Weakness in APP?
  • Or strength because its extensible?

51
Hierarchies
  • How do I model collections of collections/trees/hi
    erarchies?
  • Example

1 N
1 N
52
Hierarchical 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

53
Hierarchical 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

54
Thoughts 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

55
Eventing
  • 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

56
Security
  • Goals?
  • Privacy, Integrity, authentication, authorization
  • SSL
  • HTTP Auth
  • WSSE
  • Google Auth
  • XML Signature Encryption

57
Why not?
58
Why 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

59
Contrasts and Comparisons
  • A possibly pointless comparison to WS-

60
Comparing to WS- scaling
  • AtomPub
  • WS-
  • 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)

61
Comparisons feature applicability
  • AtomPub
  • WS-
  • 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

62
Comparisons interoperability
  • AtomPub
  • WS-
  • 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

63
Comparisons developers
  • AtomPub
  • WS-
  • 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

64
The 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

65
Questions?
  • 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
Write a Comment
User Comments (0)
About PowerShow.com