More REST

by Peter Saint-Andre

2006-12-26

Even before reading this post today I had been thinking more about REST and XMPP. At most, the principles of REST apply to XMPP request-response semantics (i.e., the stanza), because that's the only time we transfer representations from one entity to another. Consider the example of an XMPP roster (a.k.a. contact list or Buddy List [tm]) from a server to a client, as explained in RFC 3921. On logging in to its server, an IM client requests its roster with an IQ get "operation" (cf. HTTP GET). We can see this as a request to read or copy the roster from the server to the client, where the XML namespace of the IQ's child element defines the "content type" in question. The server returns an IQ result containing a copy of the roster according to the server's current understanding (i.e, the server "transfers" a "representation" of the roster to the client -- perhaps we can even say that the roster is a "resource"). The client can also update the roster via an IQ set "operation" (cf. HTTP PUT) containing a roster item or deleting an existing roster item. The update is pushed out to all other connected resources via roster pushes, obviating the need for clients to poll for changes. And there are no cookies required, because the client is authenticated with its server and the authenticated connection provides enough state for the server to do its job.

So far, so RESTful. This line of thinking doesn't apply to XMPP or stanzas, which have far different, non-request-response semantics because they don't involve the "transfer of representational state" (or do they? when I receive information about your network availability, isn't your presence state transferred to me "automatically" based on a standing subscription rather than an initiated request?). And REST principles may not even apply to all uses of the stanza (which we use in protocols like Jingle). But thinking through how REST does or does not apply to XMPP is probably a useful exercise, and may help us devise better protocol extensions. So no, I don't consider REST to be a religion (even though some people seem to); but then again I don't consider XMPP to be a religion either... ;-)


Peter Saint-Andre > Journal