Introduction to Web Services
So far you have seen several example applications in which we have called server-side scripts to carry out tasks. In each case we devised data structures to transfer the information and written routines to handle data transfer both to and from the server.
Suppose, though, that you wanted to make your server-side programs more generally available. Perhaps you can imagine that several different web applications might interface with such scripts for their own purposes. As well as browsers requesting pages directly, perhaps other applications (for example Ajax applications operating via XMLHTTPRequest calls) might also make data requests and expect to receive, in response, data that they can understand and manipulate.
In such cases it would be beneficial to have some form of standardization in the interfaces that your program makes available. This principle provides the basis of what have come to be known as web services.
As an example, suppose that our server application produces XML-formatted weather forecast data in response to a request containing geographical information.
The nature of this type of service makes it broadly applicable; such an application might have a wide variety of "clients" ranging from simple web pages that present weather forecasts in their local area to complex aviation or travel planning applications that require the data for more demanding uses.
This type of service is just one small example of what a web service might be capable of doing. Thousands of web services are active on the Internet, providing a mind-boggling array of facilities including user authentication, payment processing, content syndication, messaging, and a host of others.
In general, a web service makes available an application programming interface (API), which allows client applications to build interfaces to the service. Although any Internet protocol might be used to create web services, XML and HTTP are popular options.
A number of protocols and techniques have emerged that help you to create and utilize web services. This lesson looks at perhaps the simplest of those, called REST (Representational State Transfer), and Lesson 16, "Web Services Using SOAP," discusses another protocol, this time called SOAP (the Simple Object Access Protocol). Each lesson highlights in particular how they may be useful in Ajax applications.