31 August 2006 - 21:15REST and SOAP
I have started reading on REST-type architectures (I recommend this intro in particular). It is an interesting exercise to compare them to SOAP, one of the main differences being the amount of information a client has to know about the remote system it is interacting with. With SOAP the client must know the whole API stack in order to be able to carry out a series of actions while a REST client gets passed the resource for its next actions as it progresses. To go back to the example in the above intro: as the REST client searches the catalog it is given URIs which can be used for carrying out certain actions (viewing an article, adding it to cart, etc…). A REST client just needs to agree on the semantics of the data (how do you specify the URI for viewing an article or adding it to the shopping cart) with the server and then it just needs to call those URIs when it needs a particular action taken.
In contrast, a SOAP client needs to know the whole server API before engaging in a conversation with the server. It needs to know what method to call and what types to use in order to retrieve a product, get product information, add it to shopping cart, etc… It needs all these before else it doesn’t know what to do.
The REST architecture is very similar to the world wide web: a human being browses a page, sees some links, if they are interesting it follows them, etc… The SOAP architecture is, to a certain extent, similar to a human being using Microsoft Office: if you do not know the bazillion buttons and dropdowns MS Office comes with you cannot use it. In order to use MS Office you need to know its user guide, similar to having to know the API of a SOAP server in order to use it.
I like REST, conceptually for now, because it gives me the same feeling as when I was studying distributed computing in university: you have a node, you specify its relationships with other nodes, you set it up it in the network and before you know a whole web of relations comes alive. In REST you have to think in local terms (to what other nodes am I connected now that I am on this node and what can I do now?), while with SOAP you have to think in global terms (I know the whole application, I have this data, what do I do with it now?).
That being said, I am wondering how will REST architecture scale when the number of connections between nodes will increase. Let’s say that I have the product node and for now I have to other nodes (or URIs in REST-speak) attached to it: ordering the product and viewing it. What if I need to add 15 more actions to this node, will that affect the size of the message I am sending the client and effectively consume a lot of resources? What if these actions are not that different one from another, how will the clients be able to make a decision about where to proceed next?
Another point I’d like to make is the fact that when programming to a REST-architecture you are intimately tied to it. You cannot download the API, put a layer of abstraction on top of it and plug it into your application as you would do in a SOAP scenario. With REST you get a node, you parse it for its relationships to the rest of the application (and you have to make this all the time because the REST server may decide to change the URIs of those relationships) and then you are ready to do something. In SOAP the relationships are expressed in the API, in REST they are discovered every time you process a remote node. You are dependent on the remote server a lot more than in a SOAP scenario. Interacting with REST-servers may result in tight-coupled systems*.
One last thing (related to the above) would be the fact the REST is so different from SOAP to the point that a customer wishing to communicate with a REST-based system may have to alter its application entirely (not only the layer it uses for communicating with the rest of the world). REST doesn’t let people get their feet wet, you are either in it or totally outside of it. This could hamper mass adoption.
I am waiting to see how this unfolds. Given the fact that most corporations grok SOAP I would be surprised if this technology will make a beach-head in the enterprise space. But you never know… I, for one, wouldn’t mind getting that feeling I got in university again…
Later edit: A REST application is probably best used for distributed computing where various nodes talk to one another. In this scenario the concept of a REST client and a REST server doesn’t exist, basically the REST client is emerged in the network the REST server(s) are running. You cannot have an external (at least I don’t think so) REST client, the REST client is similar to a spider that goes from node to node carrying out certain actions at each node and finishes by becoming part of the network. I think it is for this reason that trying to connect an external system to a REST-network fails, because the external system is to intimately tied to the REST network that it finishes by becoming part of it.
Comments welcome!!
Later edit: You can abstract the interaction with a REST-server and plug it in your application, except that it is awkward mainly because REST-ful behavior is very different from your standard interaction with a library that you know before-hand.
* I am not sure about this, please drop a comment if you want to talk about it.
No Comments | Tags: Development, Favorites