SlideShare una empresa de Scribd logo
1 de 64
Descargar para leer sin conexión
Introduction to AtomPub Web Services
Ben Ramsey • International PHP Conference • 11 Oct 2010
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
Atom & AtomPub?
What’s the difference?
Atom: RFC 4287




          Introduction to AtomPub Web Services • Ben Ramsey   5
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
Atom is an XML language.
AtomPub: RFC 5023




           Introduction to AtomPub Web Services • Ben Ramsey   8
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
AtomPub is a
publishing protocol.
What about RSS?




          Introduction to AtomPub Web Services • Ben Ramsey   11
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
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
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
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
Atom was created to solve
   the RSS problems.
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
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
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
Terminology
‣ Entry

‣ Feed/Collection

‣ Category Document

‣ Service Document




                      Introduction to AtomPub Web Services • Ben Ramsey   20
Content Types
‣ Entry:
  application/atom+xml;type=entry

‣ Feed/Collection:
  application/atom+xml

‣ Category Document:
  application/atomcat+xml

‣ Service Document:
  application/atomsvc+xml




                                    Introduction to AtomPub Web Services • Ben Ramsey   21
Designing an AtomPub Service




                 Introduction to AtomPub Web Services • Ben Ramsey   22
What will our service do?
‣ Expose users

‣ Expose content

‣ Allow users to manipulate content




                                      Introduction to AtomPub Web Services • Ben Ramsey   23
Step 1:
Define our URIs
Users
‣ /user

‣ /user/{username}

‣ For example: /user/ramsey




                              Introduction to AtomPub Web Services • Ben Ramsey   25
Content
‣ /content

‣ /content/{id}

‣ For example: /content/1234




                               Introduction to AtomPub Web Services • Ben Ramsey   26
Step 2:
Define the relationships
Relationship Building
‣ user ⇛ content:
  one to many

‣ content ⇛ user:
  one to one




                        Introduction to AtomPub Web Services • Ben Ramsey   28
Step 3:
Define the interface
Methods   Cut & Paste

GET        Copy
PUT        Paste Over
POST       Paste After
DELETE     Cut
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
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
Other Actions
‣ Service discovery:
  GET /

‣ Retrieve content for a particular user:
  GET /user/ramsey/content




                                            Introduction to AtomPub Web Services • Ben Ramsey   33
Let’s see it in action




              Introduction to AtomPub Web Services • Ben Ramsey   34
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
<?xml version="1.0" encoding="utf-8"?>
<service xmlns="http://www.w3.org/2007/app"
         xmlns:atom="http://www.w3.org/2005/Atom"
         xml:base="http://atom.example.org/">
 <workspace>
  <atom:title>Our Content Store</atom:title>
  <collection href="user">
   <atom:title>Users</atom:title>
   <accept>application/atom+xml;type=entry</accept>
   <categories href="cat/user"/>
  </collection>
  <collection href="content">
   <atom:title>Content</atom:title>
   <accept>application/atom+xml;type=entry</accept>
   <categories href="cat/content"/>
  </collection>
 </workspace>
</service>
GET /user HTTP/1.1
Host: atom.example.org




HTTP/1.x 200 OK
Date: Mon, 21 Sep 2009 16:34:26 GMT
Content-Type: application/atom+xml
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"
      xmlns:app="http://www.w3.org/2007/app"
      xml:base="http://atom.example.org/">
 <title>Users</title>
 <updated>2009-09-21T05:21:19Z</updated>
 <id>tag:example.org,2009-09:user</id>
 <app:collection href="user">
  <title>Users</title>
  <app:accept>application/atom+xml;type=entry</app:accept>
  <app:categories href="cat/user"/>
 </app:collection>
 <link rel="first" href="user"/>
 <link rel="last" href="user?p=23"/>
 <link rel="next" href="user?p=2"/>
 <entry>
  ...
 </entry>
</feed>
Manipulating a User




            Introduction to AtomPub Web Services • Ben Ramsey   39
GET /user/ramsey HTTP/1.1
Host: atom.example.org




HTTP/1.x 200 OK
Date: Mon, 21 Sep 2009 16:34:26 GMT
Content-Type: application/atom+xml;type=entry
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom"
       xml:base="http://atom.example.org/">
 <title>ramsey</title>
 <author>
  <name>ramsey</name>
 </author>
 <link rel="self" href="user/ramsey"/>
 <link rel="edit" type="application/atom+xml;type=entry"
  href="user/ramsey"/>
 <link rel="related" href="user/ramsey/content"/>
 <id>tag:example.org,2008:user/ramsey</id>
 <updated>2009-09-21T13:45:00Z</updated>
 <published>2008-05-23T16:23:34Z</published>
 <content type="xhtml">
   <div class="vcard">
    <a class="fn">Ben Ramsey</a>
    <span class="tel">123-456-7890</span>
   </div>
 </content>
</entry>
Modify the Entry Locally




               Introduction to AtomPub Web Services • Ben Ramsey   42
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom"
       xml:base="http://atom.example.org/">
 <title>ramsey</title>
 <author>
  <name>ramsey</name>
 </author>
 <link rel="self" href="user/ramsey"/>
 <link rel="edit" type="application/atom+xml;type=entry"
  href="user/ramsey"/>
 <link rel="related" href="user/ramsey/content"/>
 <id>tag:example.org,2008:user/ramsey</id>
 <updated>2009-09-22T09:14:58Z</updated>
 <published>2008-05-23T16:23:34Z</published>
 <content type="xhtml">
   <div class="vcard">
    <a class="fn url" href="http://benramsey.com/">Ben Ramsey</a>
    <span class="org">Moontoast</span>
    <span class="tel">123-456-7890</span>
   </div>
 </content>
</entry>
PUT /user/ramsey HTTP/1.1
Host: atom.example.org
Content-Type: application/atom+xml;type=entry

{body here}




HTTP/1.x 200 OK
Date: Mon, 22 Sep 2009 09:14:59 GMT
Content-Type: application/atom+xml;type=entry
Add Some Content




          Introduction to AtomPub Web Services • Ben Ramsey   45
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
That’s out of scope.
:-)
But I’ll show you the basics.
<?xml version="1.0" encoding="utf-8"?>
<service xmlns="http://www.w3.org/2007/app"
         xmlns:atom="http://www.w3.org/2005/Atom"
         xml:base="http://atom.example.org/">
 <workspace>
  <atom:title>Our Content Store</atom:title>
  <collection href="user">
   <atom:title>Users</atom:title>
   <accept>application/atom+xml;type=entry</accept>
   <categories href="cat/user"/>
  </collection>
  <collection href="content">
   <atom:title>Content</atom:title>
   <accept>application/atom+xml;type=entry</accept>
   <categories href="cat/content"/>
  </collection>
 </workspace>
</service>
Get the Categories




            Introduction to AtomPub Web Services • Ben Ramsey   51
GET /cat/content HTTP/1.1
Host: atom.example.org




HTTP/1.x 200 OK
Date: Mon, 22 Sep 2009 09:39:26 GMT
Content-Type: application/atomcat+xml
<?xml version="1.0"?>
<app:categories
  xmlns:app="http://www.w3.org/2007/app"
  xmlns:atom="http://www.w3.org/2005/Atom"
  fixed="yes"
  scheme="http://atom.example.com/cat/content">
 <atom:category term="audio"/>
 <atom:category term="video"/>
 <atom:category term="game"/>
</app:categories>
Create the Entry Document Locally




                   Introduction to AtomPub Web Services • Ben Ramsey   54
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom"
       xml:base="http://atom.example.org/">
 <title>Perfect</title>
 <author>
  <name>Mark Phelps</name>
 </author>
 <id>tag:example.org,2009:content/perfect</id>
 <published>2009-09-22T20:12:08Z</published>
 <category term="audio"
  scheme="http://atom.example.com/cat/content"/>
 <content type="application/mp4">
TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWF
IHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGl
...
 </content>
</entry>
POST /content HTTP/1.1
Host: atom.example.org
Content-Type: application/atom+xml;type=entry

{body here}




HTTP/1.x 202 Accepted
Date: Mon, 22 Sep 2009 09:14:59 GMT

{body contains status indicator}
Authentication?
‣ Atom doesn’t specify a preference

‣ WSSE Username Token

‣ OAuth

‣ Basic authentication

‣ Digest authentication

‣ ???




                                      Introduction to AtomPub Web Services • Ben Ramsey   57
Did I miss anything?
Oh, yeah.

Where’s the PHP code?
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
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
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
Introduction to AtomPub Web Services
Copyright © Ben Ramsey. Some rights reserved.

This work is licensed under a Creative Commons
Attribution-Noncommercial-No Derivative Works 3.0
United States License.

For uses not covered under this license, please
contact the author.
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

Más contenido relacionado

La actualidad más candente

HTTP2:新的机遇与挑战
HTTP2:新的机遇与挑战HTTP2:新的机遇与挑战
HTTP2:新的机遇与挑战Jerry Qu
 
HTML5, HTTP2, and You 1.1
HTML5, HTTP2, and You 1.1HTML5, HTTP2, and You 1.1
HTML5, HTTP2, and You 1.1Daniel Austin
 
What HTTP/2.0 Will Do For You
What HTTP/2.0 Will Do For YouWhat HTTP/2.0 Will Do For You
What HTTP/2.0 Will Do For YouMark Nottingham
 
O'Reilly Fluent Conference: HTTP/1.1 vs. HTTP/2
O'Reilly Fluent Conference: HTTP/1.1 vs. HTTP/2O'Reilly Fluent Conference: HTTP/1.1 vs. HTTP/2
O'Reilly Fluent Conference: HTTP/1.1 vs. HTTP/2Load Impact
 
An Introduction to Apache ServiceMix 4 - FUSE ESB
An Introduction to Apache ServiceMix 4 - FUSE ESBAn Introduction to Apache ServiceMix 4 - FUSE ESB
An Introduction to Apache ServiceMix 4 - FUSE ESBAdrian Trenaman
 
PyCon 2005 PyBlosxom
PyCon 2005 PyBlosxomPyCon 2005 PyBlosxom
PyCon 2005 PyBlosxomTed Leung
 
21 Www Web Services
21 Www Web Services21 Www Web Services
21 Www Web Servicesroyans
 
HTTP/2 Update - FOSDEM 2016
HTTP/2 Update - FOSDEM 2016HTTP/2 Update - FOSDEM 2016
HTTP/2 Update - FOSDEM 2016Daniel Stenberg
 
Implementing WebServices with Camel and CXF in ServiceMix
Implementing WebServices with Camel and CXF in ServiceMixImplementing WebServices with Camel and CXF in ServiceMix
Implementing WebServices with Camel and CXF in ServiceMixAdrian Trenaman
 
HTTP/2 and Java: Current Status
HTTP/2 and Java: Current StatusHTTP/2 and Java: Current Status
HTTP/2 and Java: Current StatusSimone Bordet
 
Hosting Guide (Arabic)
Hosting Guide (Arabic)Hosting Guide (Arabic)
Hosting Guide (Arabic)webhostingguy
 
HTTP/2 What's inside and Why
HTTP/2 What's inside and WhyHTTP/2 What's inside and Why
HTTP/2 What's inside and WhyAdrian Cole
 
HTTP 2.0 – What do I need to know?
HTTP 2.0 – What do I need to know? HTTP 2.0 – What do I need to know?
HTTP 2.0 – What do I need to know? Sigma Software
 
Improving performance by changing the rules from fast to SPDY
Improving performance by changing the rules   from fast to SPDYImproving performance by changing the rules   from fast to SPDY
Improving performance by changing the rules from fast to SPDYCotendo
 
オープンソース開発者がDeNAを選ぶ理由
オープンソース開発者がDeNAを選ぶ理由オープンソース開発者がDeNAを選ぶ理由
オープンソース開発者がDeNAを選ぶ理由Kazuho Oku
 

La actualidad más candente (20)

HTTP2:新的机遇与挑战
HTTP2:新的机遇与挑战HTTP2:新的机遇与挑战
HTTP2:新的机遇与挑战
 
HTML5, HTTP2, and You 1.1
HTML5, HTTP2, and You 1.1HTML5, HTTP2, and You 1.1
HTML5, HTTP2, and You 1.1
 
What HTTP/2.0 Will Do For You
What HTTP/2.0 Will Do For YouWhat HTTP/2.0 Will Do For You
What HTTP/2.0 Will Do For You
 
O'Reilly Fluent Conference: HTTP/1.1 vs. HTTP/2
O'Reilly Fluent Conference: HTTP/1.1 vs. HTTP/2O'Reilly Fluent Conference: HTTP/1.1 vs. HTTP/2
O'Reilly Fluent Conference: HTTP/1.1 vs. HTTP/2
 
An Introduction to Apache ServiceMix 4 - FUSE ESB
An Introduction to Apache ServiceMix 4 - FUSE ESBAn Introduction to Apache ServiceMix 4 - FUSE ESB
An Introduction to Apache ServiceMix 4 - FUSE ESB
 
PyCon 2005 PyBlosxom
PyCon 2005 PyBlosxomPyCon 2005 PyBlosxom
PyCon 2005 PyBlosxom
 
Http/2
Http/2Http/2
Http/2
 
Http2
Http2Http2
Http2
 
21 Www Web Services
21 Www Web Services21 Www Web Services
21 Www Web Services
 
HTTP/2 Update - FOSDEM 2016
HTTP/2 Update - FOSDEM 2016HTTP/2 Update - FOSDEM 2016
HTTP/2 Update - FOSDEM 2016
 
Implementing WebServices with Camel and CXF in ServiceMix
Implementing WebServices with Camel and CXF in ServiceMixImplementing WebServices with Camel and CXF in ServiceMix
Implementing WebServices with Camel and CXF in ServiceMix
 
HTTP2 is Here!
HTTP2 is Here!HTTP2 is Here!
HTTP2 is Here!
 
HTTP/2 and Java: Current Status
HTTP/2 and Java: Current StatusHTTP/2 and Java: Current Status
HTTP/2 and Java: Current Status
 
Hosting Guide (Arabic)
Hosting Guide (Arabic)Hosting Guide (Arabic)
Hosting Guide (Arabic)
 
SPDY and HTTP/2
SPDY and HTTP/2SPDY and HTTP/2
SPDY and HTTP/2
 
HTTP/2 What's inside and Why
HTTP/2 What's inside and WhyHTTP/2 What's inside and Why
HTTP/2 What's inside and Why
 
HTTP 2.0 – What do I need to know?
HTTP 2.0 – What do I need to know? HTTP 2.0 – What do I need to know?
HTTP 2.0 – What do I need to know?
 
Improving performance by changing the rules from fast to SPDY
Improving performance by changing the rules   from fast to SPDYImproving performance by changing the rules   from fast to SPDY
Improving performance by changing the rules from fast to SPDY
 
オープンソース開発者がDeNAを選ぶ理由
オープンソース開発者がDeNAを選ぶ理由オープンソース開発者がDeNAを選ぶ理由
オープンソース開発者がDeNAを選ぶ理由
 
HTTP/2 Comes to Java
HTTP/2 Comes to JavaHTTP/2 Comes to Java
HTTP/2 Comes to Java
 

Destacado

Real World REST with Atom/AtomPub
Real World REST with Atom/AtomPubReal World REST with Atom/AtomPub
Real World REST with Atom/AtomPubPeter Keane
 
Bimodal / Two Speed IT and Cloud Serverless Microservice Architecture
Bimodal / Two Speed IT and Cloud Serverless Microservice ArchitectureBimodal / Two Speed IT and Cloud Serverless Microservice Architecture
Bimodal / Two Speed IT and Cloud Serverless Microservice ArchitectureRobert Wilson
 
The Rest Architectural Style
The Rest Architectural StyleThe Rest Architectural Style
The Rest Architectural StyleRobert Wilson
 
Getting Git Right
Getting Git RightGetting Git Right
Getting Git RightSven Peters
 
REST vs. Messaging For Microservices
REST vs. Messaging For MicroservicesREST vs. Messaging For Microservices
REST vs. Messaging For MicroservicesEberhard Wolff
 

Destacado (8)

Real World REST with Atom/AtomPub
Real World REST with Atom/AtomPubReal World REST with Atom/AtomPub
Real World REST with Atom/AtomPub
 
Bimodal / Two Speed IT and Cloud Serverless Microservice Architecture
Bimodal / Two Speed IT and Cloud Serverless Microservice ArchitectureBimodal / Two Speed IT and Cloud Serverless Microservice Architecture
Bimodal / Two Speed IT and Cloud Serverless Microservice Architecture
 
The Rest Architectural Style
The Rest Architectural StyleThe Rest Architectural Style
The Rest Architectural Style
 
Top Legacy Sins
Top Legacy SinsTop Legacy Sins
Top Legacy Sins
 
Linked in slides contractors
Linked in slides contractorsLinked in slides contractors
Linked in slides contractors
 
Getting Git Right
Getting Git RightGetting Git Right
Getting Git Right
 
REST vs. Messaging For Microservices
REST vs. Messaging For MicroservicesREST vs. Messaging For Microservices
REST vs. Messaging For Microservices
 
Git Branching Model
Git Branching ModelGit Branching Model
Git Branching Model
 

Similar a Introduction to AtomPub Web Services

Grokking REST (ZendCon 2010)
Grokking REST (ZendCon 2010)Grokking REST (ZendCon 2010)
Grokking REST (ZendCon 2010)Ben Ramsey
 
Atom Web Services
Atom Web ServicesAtom Web Services
Atom Web Servicesthinkphp
 
Distribution and Publication With Atom Web Services
Distribution and Publication With Atom Web ServicesDistribution and Publication With Atom Web Services
Distribution and Publication With Atom Web ServicesBen Ramsey
 
SAP REST Summit 2009 - Atom At Work
SAP REST Summit 2009 - Atom At WorkSAP REST Summit 2009 - Atom At Work
SAP REST Summit 2009 - Atom At WorkJuergen Schmerder
 
RSS and Atom in the Social Web
RSS and Atom in the Social WebRSS and Atom in the Social Web
RSS and Atom in the Social Webhchen1
 
Introduction to Dynamic Web Design Technology
Introduction to Dynamic Web Design TechnologyIntroduction to Dynamic Web Design Technology
Introduction to Dynamic Web Design Technologyarulvmax
 
Dexxter's QT feed reader
Dexxter's QT feed readerDexxter's QT feed reader
Dexxter's QT feed readerd3x3t3r
 
You Look Like You Could Use Some REST!
You Look Like You Could Use Some REST!You Look Like You Could Use Some REST!
You Look Like You Could Use Some REST!Ben Ramsey
 
Grokking the REST Architectural Style
Grokking the REST Architectural StyleGrokking the REST Architectural Style
Grokking the REST Architectural StyleBen Ramsey
 
Application layer chapter-9
Application layer chapter-9Application layer chapter-9
Application layer chapter-9Student
 
Esri Web Applications February11 2011
Esri Web Applications February11 2011Esri Web Applications February11 2011
Esri Web Applications February11 2011delmelle
 

Similar a Introduction to AtomPub Web Services (20)

Grokking REST (ZendCon 2010)
Grokking REST (ZendCon 2010)Grokking REST (ZendCon 2010)
Grokking REST (ZendCon 2010)
 
Plone Web Services
Plone Web ServicesPlone Web Services
Plone Web Services
 
Plone Web Services
Plone Web ServicesPlone Web Services
Plone Web Services
 
Atom Web Services
Atom Web ServicesAtom Web Services
Atom Web Services
 
Distribution and Publication With Atom Web Services
Distribution and Publication With Atom Web ServicesDistribution and Publication With Atom Web Services
Distribution and Publication With Atom Web Services
 
5-WebServers.ppt
5-WebServers.ppt5-WebServers.ppt
5-WebServers.ppt
 
SAP REST Summit 2009 - Atom At Work
SAP REST Summit 2009 - Atom At WorkSAP REST Summit 2009 - Atom At Work
SAP REST Summit 2009 - Atom At Work
 
Web services intro.
Web services intro.Web services intro.
Web services intro.
 
Web Services
Web ServicesWeb Services
Web Services
 
RSS and Atom in the Social Web
RSS and Atom in the Social WebRSS and Atom in the Social Web
RSS and Atom in the Social Web
 
Introduction to Dynamic Web Design Technology
Introduction to Dynamic Web Design TechnologyIntroduction to Dynamic Web Design Technology
Introduction to Dynamic Web Design Technology
 
Restful webservices
Restful webservicesRestful webservices
Restful webservices
 
An Introduction to On-Demand, Web-Based Publishing
An Introduction to On-Demand, Web-Based PublishingAn Introduction to On-Demand, Web-Based Publishing
An Introduction to On-Demand, Web-Based Publishing
 
Dexxter's QT feed reader
Dexxter's QT feed readerDexxter's QT feed reader
Dexxter's QT feed reader
 
Atom and rss
Atom and rssAtom and rss
Atom and rss
 
You Look Like You Could Use Some REST!
You Look Like You Could Use Some REST!You Look Like You Could Use Some REST!
You Look Like You Could Use Some REST!
 
Grokking the REST Architectural Style
Grokking the REST Architectural StyleGrokking the REST Architectural Style
Grokking the REST Architectural Style
 
5-WebServers.ppt
5-WebServers.ppt5-WebServers.ppt
5-WebServers.ppt
 
Application layer chapter-9
Application layer chapter-9Application layer chapter-9
Application layer chapter-9
 
Esri Web Applications February11 2011
Esri Web Applications February11 2011Esri Web Applications February11 2011
Esri Web Applications February11 2011
 

Más de Ben Ramsey

Api Versioning
Api VersioningApi Versioning
Api VersioningBen Ramsey
 
Desktop Apps with PHP and Titanium (ZendCon 2010)
Desktop Apps with PHP and Titanium (ZendCon 2010)Desktop Apps with PHP and Titanium (ZendCon 2010)
Desktop Apps with PHP and Titanium (ZendCon 2010)Ben Ramsey
 
Caching with Memcached and APC
Caching with Memcached and APCCaching with Memcached and APC
Caching with Memcached and APCBen Ramsey
 
Desktop Apps with PHP and Titanium
Desktop Apps with PHP and TitaniumDesktop Apps with PHP and Titanium
Desktop Apps with PHP and TitaniumBen Ramsey
 
Give Your Site a Boost with Memcache
Give Your Site a Boost with MemcacheGive Your Site a Boost with Memcache
Give Your Site a Boost with MemcacheBen Ramsey
 
Hidden Gems in HTTP
Hidden Gems in HTTPHidden Gems in HTTP
Hidden Gems in HTTPBen Ramsey
 
Making the Most of HTTP In Your Apps
Making the Most of HTTP In Your AppsMaking the Most of HTTP In Your Apps
Making the Most of HTTP In Your AppsBen Ramsey
 
Around the PHP Community
Around the PHP CommunityAround the PHP Community
Around the PHP CommunityBen Ramsey
 
Distribution and Publication With Atom Web Services
Distribution and Publication With Atom Web ServicesDistribution and Publication With Atom Web Services
Distribution and Publication With Atom Web ServicesBen Ramsey
 

Más de Ben Ramsey (9)

Api Versioning
Api VersioningApi Versioning
Api Versioning
 
Desktop Apps with PHP and Titanium (ZendCon 2010)
Desktop Apps with PHP and Titanium (ZendCon 2010)Desktop Apps with PHP and Titanium (ZendCon 2010)
Desktop Apps with PHP and Titanium (ZendCon 2010)
 
Caching with Memcached and APC
Caching with Memcached and APCCaching with Memcached and APC
Caching with Memcached and APC
 
Desktop Apps with PHP and Titanium
Desktop Apps with PHP and TitaniumDesktop Apps with PHP and Titanium
Desktop Apps with PHP and Titanium
 
Give Your Site a Boost with Memcache
Give Your Site a Boost with MemcacheGive Your Site a Boost with Memcache
Give Your Site a Boost with Memcache
 
Hidden Gems in HTTP
Hidden Gems in HTTPHidden Gems in HTTP
Hidden Gems in HTTP
 
Making the Most of HTTP In Your Apps
Making the Most of HTTP In Your AppsMaking the Most of HTTP In Your Apps
Making the Most of HTTP In Your Apps
 
Around the PHP Community
Around the PHP CommunityAround the PHP Community
Around the PHP Community
 
Distribution and Publication With Atom Web Services
Distribution and Publication With Atom Web ServicesDistribution and Publication With Atom Web Services
Distribution and Publication With Atom Web Services
 

Último

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 

Último (20)

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 

Introduction to AtomPub Web Services

  • 1. Introduction to AtomPub Web Services Ben Ramsey • International PHP Conference • 11 Oct 2010
  • 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
  • 7. Atom is an XML language.
  • 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
  • 16. Atom was created to solve the RSS problems.
  • 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
  • 20. Terminology ‣ Entry ‣ Feed/Collection ‣ Category Document ‣ Service Document Introduction to AtomPub Web Services • Ben Ramsey 20
  • 21. Content Types ‣ Entry: application/atom+xml;type=entry ‣ Feed/Collection: application/atom+xml ‣ Category Document: application/atomcat+xml ‣ Service Document: application/atomsvc+xml Introduction to AtomPub Web Services • Ben Ramsey 21
  • 22. Designing an AtomPub Service Introduction to AtomPub Web Services • Ben Ramsey 22
  • 23. What will our service do? ‣ Expose users ‣ Expose content ‣ Allow users to manipulate content Introduction to AtomPub Web Services • Ben Ramsey 23
  • 25. Users ‣ /user ‣ /user/{username} ‣ For example: /user/ramsey Introduction to AtomPub Web Services • Ben Ramsey 25
  • 26. Content ‣ /content ‣ /content/{id} ‣ For example: /content/1234 Introduction to AtomPub Web Services • Ben Ramsey 26
  • 27. Step 2: Define the relationships
  • 28. Relationship Building ‣ user ⇛ content: one to many ‣ content ⇛ user: one to one Introduction to AtomPub Web Services • Ben Ramsey 28
  • 29. Step 3: Define the interface
  • 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
  • 36. <?xml version="1.0" encoding="utf-8"?> <service xmlns="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xml:base="http://atom.example.org/"> <workspace> <atom:title>Our Content Store</atom:title> <collection href="user"> <atom:title>Users</atom:title> <accept>application/atom+xml;type=entry</accept> <categories href="cat/user"/> </collection> <collection href="content"> <atom:title>Content</atom:title> <accept>application/atom+xml;type=entry</accept> <categories href="cat/content"/> </collection> </workspace> </service>
  • 37. GET /user HTTP/1.1 Host: atom.example.org HTTP/1.x 200 OK Date: Mon, 21 Sep 2009 16:34:26 GMT Content-Type: application/atom+xml
  • 38. <?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xml:base="http://atom.example.org/"> <title>Users</title> <updated>2009-09-21T05:21:19Z</updated> <id>tag:example.org,2009-09:user</id> <app:collection href="user"> <title>Users</title> <app:accept>application/atom+xml;type=entry</app:accept> <app:categories href="cat/user"/> </app:collection> <link rel="first" href="user"/> <link rel="last" href="user?p=23"/> <link rel="next" href="user?p=2"/> <entry> ... </entry> </feed>
  • 39. Manipulating a User Introduction to AtomPub Web Services • Ben Ramsey 39
  • 40. GET /user/ramsey HTTP/1.1 Host: atom.example.org HTTP/1.x 200 OK Date: Mon, 21 Sep 2009 16:34:26 GMT Content-Type: application/atom+xml;type=entry
  • 41. <?xml version="1.0" encoding="utf-8"?> <entry xmlns="http://www.w3.org/2005/Atom" xml:base="http://atom.example.org/"> <title>ramsey</title> <author> <name>ramsey</name> </author> <link rel="self" href="user/ramsey"/> <link rel="edit" type="application/atom+xml;type=entry" href="user/ramsey"/> <link rel="related" href="user/ramsey/content"/> <id>tag:example.org,2008:user/ramsey</id> <updated>2009-09-21T13:45:00Z</updated> <published>2008-05-23T16:23:34Z</published> <content type="xhtml"> <div class="vcard"> <a class="fn">Ben Ramsey</a> <span class="tel">123-456-7890</span> </div> </content> </entry>
  • 42. Modify the Entry Locally Introduction to AtomPub Web Services • Ben Ramsey 42
  • 43. <?xml version="1.0" encoding="utf-8"?> <entry xmlns="http://www.w3.org/2005/Atom" xml:base="http://atom.example.org/"> <title>ramsey</title> <author> <name>ramsey</name> </author> <link rel="self" href="user/ramsey"/> <link rel="edit" type="application/atom+xml;type=entry" href="user/ramsey"/> <link rel="related" href="user/ramsey/content"/> <id>tag:example.org,2008:user/ramsey</id> <updated>2009-09-22T09:14:58Z</updated> <published>2008-05-23T16:23:34Z</published> <content type="xhtml"> <div class="vcard"> <a class="fn url" href="http://benramsey.com/">Ben Ramsey</a> <span class="org">Moontoast</span> <span class="tel">123-456-7890</span> </div> </content> </entry>
  • 44. PUT /user/ramsey HTTP/1.1 Host: atom.example.org Content-Type: application/atom+xml;type=entry {body here} HTTP/1.x 200 OK Date: Mon, 22 Sep 2009 09:14:59 GMT Content-Type: application/atom+xml;type=entry
  • 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
  • 47. That’s out of scope.
  • 48. :-)
  • 49. But I’ll show you the basics.
  • 50. <?xml version="1.0" encoding="utf-8"?> <service xmlns="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xml:base="http://atom.example.org/"> <workspace> <atom:title>Our Content Store</atom:title> <collection href="user"> <atom:title>Users</atom:title> <accept>application/atom+xml;type=entry</accept> <categories href="cat/user"/> </collection> <collection href="content"> <atom:title>Content</atom:title> <accept>application/atom+xml;type=entry</accept> <categories href="cat/content"/> </collection> </workspace> </service>
  • 51. Get the Categories Introduction to AtomPub Web Services • Ben Ramsey 51
  • 52. GET /cat/content HTTP/1.1 Host: atom.example.org HTTP/1.x 200 OK Date: Mon, 22 Sep 2009 09:39:26 GMT Content-Type: application/atomcat+xml
  • 53. <?xml version="1.0"?> <app:categories xmlns:app="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" fixed="yes" scheme="http://atom.example.com/cat/content"> <atom:category term="audio"/> <atom:category term="video"/> <atom:category term="game"/> </app:categories>
  • 54. Create the Entry Document Locally Introduction to AtomPub Web Services • Ben Ramsey 54
  • 55. <?xml version="1.0" encoding="utf-8"?> <entry xmlns="http://www.w3.org/2005/Atom" xml:base="http://atom.example.org/"> <title>Perfect</title> <author> <name>Mark Phelps</name> </author> <id>tag:example.org,2009:content/perfect</id> <published>2009-09-22T20:12:08Z</published> <category term="audio" scheme="http://atom.example.com/cat/content"/> <content type="application/mp4"> TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWF IHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGl ... </content> </entry>
  • 56. POST /content HTTP/1.1 Host: atom.example.org Content-Type: application/atom+xml;type=entry {body here} HTTP/1.x 202 Accepted Date: Mon, 22 Sep 2009 09:14:59 GMT {body contains status indicator}
  • 57. Authentication? ‣ Atom doesn’t specify a preference ‣ WSSE Username Token ‣ OAuth ‣ Basic authentication ‣ Digest authentication ‣ ??? Introduction to AtomPub Web Services • Ben Ramsey 57
  • 58. Did I miss anything?
  • 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
  • 63. Introduction to AtomPub Web Services Copyright © Ben Ramsey. Some rights reserved. This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License. For uses not covered under this license, please contact the author.
  • 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