Jim, REST, Resources, and Services

Those who know Jim and me well always wonder how we can possible work together and produce interesting work since we seem to constantly argue and disagree on things… from who’s the uglier of the two (I usually let him win on this one :-), on all things technology related. I really enjoy working with Jim and especially our disagreements because I learn a lot. Of course, at the end we always seem to come up with a common approach, a single answer. Since we started this blogging thing, however, we have been mostly writing things that we had previously agreed on and kept our discussions private. Well, I think this may be the first time that we are going to disagree through our blogs 🙂 Well… at the end it may not seem really as a disagreement but let’s see how it goes…

Jim posted some very interesting thoughts on REST and our “processThis” (post1, post2) (we are still looking for a better name… any suggestions?) approach. I agree with Jim that transport independence is good but he also suggested that the REST architectural style mixes the semantics of SOAP with those of the underlying transport protocols. I personally don’t think that this is the main issue with REST. At least, it’s not the main reason I prefer service-orientation and the focus on the messages over REST. Also, I disagree with Mark Baker who suggests that the transport-dependence is the main reason some of us prefer service-orientation over REST, DCOM, CORBA, etc.

I personally see REST as a resource-oriented architectural style for building distributed applications. I see its simplicity, its focus on document exchanges (or state representations), and its constrained set of operations with uniform semantics (at the architectural level) as very good steps forward from the traditional object-oriented dominated world of distributed computing. However, REST promotes the resource and its state as the fundamental building block. It encourages the idea of having a set of fixed operations, which are derived by the resource URI’s associated specification; only these operations should be used on/with those resources (e.g., HTTP “GET” source-resource-uri or FTP “PUT” destination-resource-uri or even MYPROTOCOL “SAY” source-resource-uri). At the architectural level, the resources are seen as having state, hence the need to transfer it. It’s this focus on resources and their state that I am not fond of. And if one considers the easily breakable interrelationships that can be formed between resources through the inclusion of URIs in their states, the fragility and maintainability of distributed applications may (but not always) become a major headache.

Furthermore, REST promotes the idea of separating the application protocol from the representation of state but does not attempt to hide that state. REST treats transport protocols like HTTP and FTP as application protocols. Yes, I know… one could define a new application protocol, with a new URI, that was different from the existing transport protocols. However, because the focus is on resources and their state, that protocol would still have to look like a transport one. This is because the new protocol will need operations which, at the architectural level, would have transport-related semantics (e.g., “place”, “retrieve”, “put”, “get”, “move”, etc.) for moving state.

In service-orientation there is no such thing as a resource. That doesn’t mean of course that resources don’t exist; they exist, but it’s just they are not modelled explicitly at the architecture. What Jim and I say with the “processThis” approachs is that there is one verb to rule them all :-). We base our architecture on services with each service having the ability to either receive an instruction to process a message or instruct another service to do the same. We then advocate that the structure and contents of the message is important. It’s from the exchange of these messages that we can build scalable, loosely-coupled applications. Of course, these properties are not guaranteed 🙂

In our approach, we don’t separate the messages and the information exchanged from the application protocol. In fact, there is no such thing as an application protocol common to all applications; there are message exchange patterns and the contents of the messages. The semantics of a collection of a message exchange patterns may be referred to as a “protocol” (e.g., WS-Security, WS-TransactionManagement, WS-FlowerShop). State as we know it is not a first-class citizen. It’s there, services operate on it, we know about its existence but we don’t make it part of our architecture.

I may be wrong on all these of course, so I am sure Jim will put in my place. Hey mate… looking forward to your response.

7 responses to “Jim, REST, Resources, and Services”

  1. Hey mate, Sorry but I don’t really see the disagreement. You happen to dislike things about REST that I also dislike but didn’t write about – I just wanted to point out that REST is a point on the learning curve. For the record I also think that resource-orientation will lead us into a 404 nightmare. So no public spat yet mate. Unless you count that week where Chris Phillips saw us on several consecutive evenings and eventually asked us whether we were still arguing over the same thing 🙂 Jim
  2. Hey. Before I respond, I’d like to ask a question; how would you define “transport” and “transfer”, and how do you see them relating? (because you are clearly using the terms differently than the rest of the world; FTP and HTTP are not transport protocols) Also, how do you see the “processMessage” fitting in?
  3. Hey Mark. I think that the definition of the terms is relative and not absolute in architecture terms. In my view and in the way I personally see the architecture, a transport protocol defines the mechanisms by which one message is moved from A to B. A trasnfer protocol defines how that message should be structured so it can move information from A to B _using_ a transport protocol. Of course, one’s trasfer protocol may be another’s transport protocol. For SOAP, I see TCP/IP, SMTP, HTTP, JMS, etc. as transport protocols because SOAP is the transfer protocol. Obviously, for REST, HTTP, FTP, etc. are transfer protocols with TCP/IP being the transport protocol. That’s the difference I see. Now, how does “processMessage” fit in? That’s an abstract operation that we assume can be implemented by a transport protocol. Hence, the requirements on the transport protocol are minimal.
  4. Ok, thanks. One final question; how do you see processMessage relating to transfer protocols?
  5. I see “processMessage” as that abstract operation that provides the link between the transport and the transfer protocols. A mechanism to transport a message from one point to the other must exist. For example, the combination of socket:send and socket:receive, HTTP POST, FTP PUT, etc. The semantics of “processMessage” suggest that once a message has been received, it must be processed according to the semantics of the transfer protocol. Only then, the transfer of the message can be considered as completed. That’s why I personally see it as the link between the transport and transfer layers. In other words, a message may be transported but not transferred if it has not been received for processing.
  6. Mark: Don’t focus on the “operation” processThis. It’s a mental crutch only. Web Services never had operations, just that WSDL pretended they did. Jim
  7. Hi Jim. Well, if it walks like a duck and quacks like a duck … Thanks Savas, I think I have enough to respond with… maybe. We’ll see. There’s a disconnect here, not just a disagreement. I’m trying to track it down.