Is your code RESTful

[Concrete/Important] Well nearly, but not 100% - well not yet.

A few years ago I wrote an HTTP GET/POST web service (sounds RESTful) between a Windows CE.Net client on a hand held device and an Apache server running a light SOAP Web Service. It wasn’t hard to write but the messages were specialized, so fell short of being a true RESTful implementation.

REST stands for REpresentational State Transfer and refers to an architectural style or pattern. In essence it describes clients served by services where state transitions or transfers in the client take place through the representation of a new state in the data returned by the service.

Web applications architected in this way have stateless servers and would typically map messages or web service requests onto the HTTP verbs GET/PUT/POST/DELETE.

At its core, my latest project http://www.far2muchmail.com/ , uses messaging between an Outlook desktop client and a web service. The web service is in PHP and not currently highly scalable. Over the last couple of years I’ve been using XML-RPC and make extensive use of this for messaging between my Outlook plug-in and the web service. However, I’m thinking about making a more RESTful approach.

But XML-RPC is cool. It is well supported by the guys at http://www.xml-rpc.com/ and others around the world. It provides remote execution interoperable between .Net and PHP and many others like Perl, Python, Ruby, Objective C... I really love it.

Client side under .Net, its asynchronous so you need to think about a RESTfully and this is typically how I use it.

So what’s wrong with XML-RPC, it certainly works for http://www.far2muchmail.com/.

Well it does now. However, XML-RPC has a few niggles. First it’s bound to HTTP, not really a problem but it might be if I want to move my services inside the cloud.

XM-RPC is also a bit verbose – the XML message that is. And it gets worse with binary data. This also leads to weak implementations and misinterpretation of the protocol. So if you want to talk to a public service, you may have to code for that particular implementation.

So, if you want to move to a more scalable service architecture, XML-RPC may not be your first choice.

REST based on HTTP verbs is now well established, very lightweight and simple to interpret. With the big players like Microsoft, Google and Amazon adopting the RESTful approach and providing a REST interface to anything that moves, it may be time to start thinking RESTfully.

And as REST builds momentum we are going to see a lot more services out there that speak to REST clients, including services hosted in the cloud (Cloud Services). This should mean that in the near future you should be able to benefit from high scale platforms running scalable services, on premise and in the cloud, ranging from business application services through to storage and bus and communication services... all speaking RESTfully.

So for me at least, I think it is worth taking a more RESTful approach.

Comments

Popular posts from this blog

"Better to say nothing and be thought a fool..."

Carving Rings

Using IActiveAware and INavigationAware