Coupling in REST
Savas worries about embedding URIs in resource state:
My worry about this approach is that there is a coupling of an identifier (the URI), an interface (HTTP verbs), and the state on which these verbs operate. The approach may work for the web but as we attempt to build large-scale, distributed applications that do not involve the human factor, we may get complex networks of references between the states of resources containing references to other resources which, in turn, may lead to brittle applications.
A service that depends on being able to dereference a URL embedded in its state is indeed susceptible to failure if the authority serving the URL is unreliable. For example, step three of REST goes to Maui depends on being able to dereference the POSTed Reply-To, Status-To, and payment URLs. Is that an accurate summary of your concern, Savas?
It’s a good point and something that REST designs need to address if they depend on URLs. I would expect similar issues among aggregators of Web Services. How would you address the possibility that a Web Service might stop returning messages in a certain format or just suddenly cease to exist? I am hopeful that general principles to solve this problem in Web Services might yield clues to solving it in REST as well (or vice versa). Anyone care to offer a design pattern that addresses this?
URNs are not protocol specific, while URIs carry some protocol specific information. Also, we do not assume a coupling of the identified resource and the means by which the resource can be accessed.
URI, URN, URL–I try to be very careful to use URL only when I’m talking about a locator, and URI for everything else. I don’t typically use URN because we are increasingly using HTTP URIs as URNs. XML Namespaces and RDF, for example. I conjure up a URI by fiat:
http://www.geekaboo.net/names/garland/matt/
It doesn’t necessarily locate anything, it just identifies/names me or whatever else I choose for it to represent. A nice side effect is that it may locate something, but again, if I want reliability, I really shouldn’t depend on what it locates being anything in particular.
This usage is normative. The URI spec section 1.1 is clear that the “uniform” in URI (of which URN is a subset) means that URIs can be reused in contexts other than the protocol for which they were originally developed. Section 1.2 goes on to say that URIs can be both locators and names at the same time.
Savas’ advice to use URNs sounds good to me, but note that RFC 2396 permits me to use HTTP URIs (treating them as URNs) to the same effect. Whether I choose to couple that HTTP URI to the HTTP protocol is really just an implementation detail.
Mark Baker, how do you deal with these issues?
May 13th, 2004 at 10:39 pm
Re URI/URL/URN, I just use “URI”. Even URLs “identify”. And sure, you can have http URIs which are dereferenceable, but why would you do that? Even if you just put an HTML description of what the URI identifies behind it, you’ve improved its utility enormously.
Regarding services which “might stop returning messages in a certain format or just suddenly cease to exist”, that’s not going away; it’s a fundamental part of distributed communication in the face of trust boundaries. So while I can’t stop you from retiring a service, the best we can hope for is that you tell me it’s retired; for example, with an HTTP service, you’d tell me that by returning a 410 (Gone) response code.