21 September 2010

What's the point of web services?

By Andrew Clifford

Web services are not just an advanced technology for sophisticated web solutions. They also meet down-to-earth requirements like testing and integration.

Web services allow one computer to access data or functions on another computer, using the same technologies used to access web pages. The World Wide Web Consortium (W3C) defines specific technical standards for web services. Most people use the term more loosely to mean any application programming interface that can be accessed over the web.

You might think that web services are something sophisticated, for example something you would only need if you want to make your system available as part of a Web 2.0 mashup (whatever that is).

However, if you follow the loose definition, it is surprisingly easy to write web services, and you can use them for very down-to-earth requirements.

To give an example, we provide a web-based system for assessment and data analysis. We want to allow partner organisations to create solutions in which users sign on to the partner's system and then gain access securely to the capability in ours without signing on again.

To do this we need to provide a web service. We use a very simple approach – passing standard web query parameters to the server, and returning results as XML. This was easy for us to implement because we use XML internally in our system, but even without this building simple web services is no harder than building a simple web application. We decided to allow access to all the functionality of the system through this secure web service interface.

This has opened up up all sorts of new possibilities.

Rich applications. Our standard web interface deliberately avoids advanced gadgetry because it can clutter the user experience. However, in a few places, we could do with a more dynamic interface, for example to show users when background analyses have finished without having to refresh the page. With web services, we can access functionality directly from scripts in the browser, making it relatively easy to create a more dynamic user interface.

Data setup and configuration. In some cases, our system needs a reasonable amount of setup, for example to define a large number of new users. Web services make it easy to build scripts that import data from other structures.

Testing. We have regression tests for both back-end functionality and the user interface. Setting up test data for the user interface is hard when the test system is running remotely. Web services allow us to call the system directly, making test data setup much easier.

Integration. Web services provide a well-defined integration point for any functionality. For example, we could use it to export questions to a simple survey tool, and import captured answers to ours for more in-depth analysis.

Web services sound like they are hard to implement, and are only required for sophisticated systems that need complicated Web 2.0 functionality. We have found that simple web services are as easy to implement as a basic web application, and that they provide a single, consistent mechanism to meet many down-to-earth requirements, such as building more dynamic applications, data setup, testing and integration.