We’ve been talking for a couple of days now in our information architecture class about Service Oriented Architecture (SOA). Although SOA isn’t exclusively based around web services, web services play an important role. So far, we’ve only discussed SOAP web services in class, but I’d like to talk about some of the other popular web services protocols, xml-rpc, and REST. I’m going to start with the most simple web service and work my way to the more complicated.

REST – stands for Representational State Transfer (wikipedia reference) but that’s not really that important. Basically, REST web services consist of using plain old HTTP to make method calls and you get XML back. The true RESTful way is to use GET, POST, PUT, and DELETE calls to access CRUD (Create, Read, Update, Delete) operations on an object. In that light, a GET request is your “Read,” POST is your “Create,” PUT is your “Update,” and DELETE is your “Delete” operation. Any parameters are sent as normal http parameters, either in the query string of a GET request, or in the query string of a POST request.

While the use of the above HTTP methods are ideal for this kind of web services interactions, it’s not commonly practiced. Rails is the first framework that I’ve seen that is doing any serious development and seamless support for this type of web services integration with its Active Resources library. It doesn’t come standard in Ruby on Rails, but you can get it as a plug-in.

There are a ton of web services out there that offer a REST like web services interface. They all just don’t adhere to the GET, POST, PUT, standards. They are more like xml document requests via GET or POST. For example, Yahoo! has a handful of web services that you can access via REST, including its Answers, Local, and Flickr services.

REST style web services are what power AJAX applications. The browser makes a request to a REST web service via JavaScript’s XMLHttpRequest object. The browser then parses the xml and replaces elements in the page with the data.

REST is really quite simple. If you would like to connect to some REST web services, check out my previous post on resources to help you connect to web services.

XML-RPC – is a remote procedure call protocol which uses XML for marking up both requests and responses (see wikipedia’s reference). It was created by Dave Winer of UserLand Software and Microsoft. UserLand was one of the early providers of blogging software, and thus XML-RPC is commonly used for blog ping services such as Technorati and Ping-o-Matic.

XML-RPC protocol is really simple. You pass requests which contain the method name, and parameters wrapped in xml that defines their data types. The response comes back with similar data.

XML-RPC servers are easier to implement than SOAP when using scripting languages such as php which have very loose data typing. Php has a nice PEAR library that you can install and use to handle XML-RPC client and server scripting. Ruby on Rails has built-in support for creating and connecting to xml-rpc web service. I’m sure there are other nice tools for the other languages that help you seamlessly connect to and create XML-RPC web services. If anyone knows of any good libraries, please comment.

According to wikipedia, XML-RPC is the predecessor to SOAP, which took XML-RPC to a more complex level.

SOAP – stands for Simple Object Access Protocol (see wikipedia’s reference). Accessing a SOAP web service is super easy with any language that has SOAP libraries to help you. All you have to do is point your code to the url of the web service’s WSDL, and you’re off and running, making remote calls as you would to a local object.

SOAP begins to be not so simple when you pull back the curtains and look at the innards that make it all work. Reading or creating a WSDL document is not an easy task. However, I’ve written a tutorial on how to get a SOAP server with php5.

PHP5 has a SOAP library that will handle your client and server, but you have to create your own WSDL. I’ve seen a few SOAP servers implemented using NuSOAP, a php library, but there is rarely a wsdl provided, and it can only be connected to by other NuSOAP clients from what I can tell.

Ruby on Rails has SOAP client and server capabilities, and doesn’t make you write your wsdl by hand. BenRobb has written a post on how to set up your web service in Rails.

I don’t have any experience creating SOAP servers in .NET, but I hear it is super slick. Java has a plethora of tools for doing SOAP. While I am comfortable programming in Java and I understand basic J2EE principles, I don’t have much experience with Java web services either.

Side By Side – Flickr gives some good examples of what a request and response would look like for each of these web services.