XML Web Services


Before delving into how to use Web Services, you must understand what they are. You cannot pick up a computer trade magazine or programming journal these days without seeing them mentioned, often in a context so euphoric that you might find yourself wondering whether XML Web Services will solve world hunger, eliminate global warming, or reveal the secret of life. An understanding of their utility and how XML (see Chapter 23, "XML and XHTML") fits into the picture will help clear up much of the confusion and hullabaloo.

Setting the Stage

As discussed in Chapter 23, whenever people wanted to share proprietary information with each other in the "good old days" of computing (that is, 10 years ago), they had to sit down and agree on the format of the data, the method for exchanging it, and the means of validating it.

Similarly, when companies wanted to share functionalitya bank in New York wanted to provide stock ticker services (for a fee, of course)the company that exposed these services would design a delightfully baroque mechanism via which people would communicate with their servers and extract the necessary information. This system often was based entirely on proprietary protocols (such as a binary mechanism called remote procedure calls or RPC) and was specific to a particular operating system, programming language, or network type. Developers frequently had only a small document that some intern wrote as a summer project for the developers of the system.

Overall, people did not expose functionality for widespread consumption, contenting themselves to releasing content using well-established means such as HTTP and the World Wide Web to distribute information. Those people who did want to try to get information from existing sites often used what came to be called screen scraping to get what they wanted. If somebody wanted to get the top-seller list from Amazon.com, he downloaded any relevant web pages in HTML format from the web site and parsed the markup himself, extracting what was needed. This process was error-prone and broke every time a web site changed anything about its presentation.

With the arrival of XML in the late 1990s, however, people began to see another possibility: XML Web Services.

Enter XML Web Services

XML Web Services is a technology that allows for the exposure and consumption of functionality (typically in the form of function calls and replies) over HTTP, independent of platform, language, or network (see Figure 27-1). Description, discovery, and transport are all handled by XML and transmitted over the Internet via HTTP. With no real requirements on the underlying platform, it is easy to see how people have gotten so excited.

Figure 27-1. XML Web Services are based on HTTP.


However, Web Servicesafter you cut through the hypeare not all that complicated or glamorous. They are just a new part of the plumbing that makes up the Internet. Major web sites that are already extremely popular today are now exposing interfaces to people via XML Web Services to further expand the reach of their influence and services.

Web Services are an ideal way for people to offer application services for those businesses that are not so content-basedsearch engines could let people execute searches through a simple set of functions, applications could query weather from national weather centers, and credit card processing companies could offer services to realize financial transactions. Because all of this is done over HTTP, little new work in terms of setting up security or network infrastructure needs take place. Most modern networks allow HTTP traffic to pass through (whereas older binary RPC schemes are largely blocked by firewalls).

Web Services provide a number of key benefits:

  • Web Services are interoperable Because the key description and transmission are done using XML over HTTP, the underlying server or client can be implemented in any language that supports both of these technologies. Therefore, you now see services used in languages such as C/C++, Java, Perl, Ruby, BASIC, and, of course, PHP. Operating system requirements have all but been eliminatedany computer that can connect to the Internet (including telephones and PDAs) can use Web Services.

  • XML Web Services are easy to use XML is very easy to learn, and the documents that make up Web Services (discussed in the section "How Web Services Work") are largely straightforward. Many programming environments ship with tools to help automate much of the process, particularly for those one or two parts that are not glaringly trivial.

  • Web Services can be accessed from anywhere on the Internet Although we are not absolutely obliged to create public Web Serviceswe certainly could create some for internal use on our corporate intranetsthe fact that they operate over HTTP means that we can create services that anybody can consume, helping us to expose new functionality and adding a whole programmable level to the Internet.

  • No new technologies are required to make XML Web Services work HTTP is a well-known and established protocol, and XML has become a popular and powerful document description format. All that XML Web Services required were a couple of new document types and a description of how to tie all of this together to make function invocations possible.

Finding Web Services

You might not realize it, but a large number of publically accessible XML Web Services are available today. Finding them, however, can prove a bit tricky. The same groups and companies that originally pushed the various specifications that make up XML Web Services also proposed an additional technology called Universal Description, Discovery, and Information, or UDDI. This is intended as a global phone book of available web services, along with restrictions on use, costs, and so forth.

Unfortunately, UDDI is not quite mainstream yet. The best places to find out about available Web Services remain a number of useful sites on the Internet, such as http://www.xmethods.com, http://www.webservicelist.com, or http://www.salcentral.com. From these sites, you can browse the information for the various services, often see some documentation on how to use them, and learn about the restrictions on their use.




Core Web Application Development With PHP And MYSQL
Core Web Application Development with PHP and MySQL
ISBN: 0131867164
EAN: 2147483647
Year: 2005
Pages: 255

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net