mark nottingham

XCAP

Thursday, 29 May 2003

HTTP APIs

Jonathan Rosenberg published a new Internet-Draft, XCAP, to the SIMPLE Working Group in the IETF. Here’s the skinny:

This specification defines the Extensible Markup Language (XML) Configuration Access Protocol (XCAP). XCAP allows a client to read, write and modify application configuration data, stored in XML format on a server. XCAP is not a new protocol. XCAP maps XML document sub-trees and element attributes to HTTP URIs, so that these components can be directly accessed by HTTP.

[…]

With a standardized naming convention for components of XML documents, the basic operations for accessing the data are simple. Reading one of the components is just a standard HTTP GET operation. Writing, creating or modifying one of the components is a standard HTTP POST or PUT operation. Deleting a component is just a standard DELETE operation. For example, to add a friend to a presence list, a client would construct an XML document fragment which contains the information on that friend. The client would then construct a URI that refers to the location in the presence list document where this new fragment is to be added. The client then performs a POST operation against the URI, placing the document fragment into the body of the POST request. To provide atomic read/modify/write operations, the HTTP If-Unmodified-Since header field is used. The HTTP POST operation used by the client would contain the date obtained in the Last-Modified header field from the GET used to read the data.

Cool stuff - very RESTful, very useful. I haven’t read all of the details yet, but it seems to hit a very sweet spot in functionality. I still have to think about whether it’s better to make the xpath expression a child resource of the document URI (e.g., foo.xml/xpath/here rather than foo.xml?xpath/here). Also, he recommends using Last-Modified/If-Modified-Since to avoid writing problems, but ETag/If-Match is stronger - LM only has a granularity of a second. Still, a great start!

Implementation should be a snap (especially with Tarawa ;)