ASP.NET XML Web services enable you to remotely access the properties and methods of classes across a network. They are an important part of the Microsoft vision of the programmable Web.
The Web, as it currently exists, is designed around humans browsing Web pages through a Web browser. Typically, the only way to present information through the Internet is to build a Web page designed to be consumed by human eyes.
However, in many situations, exposing information to an application makes more sense than exposing it to a human.
Consider, for example, the process of buying a book online. Currently, to buy a book, you must complete each of the following steps:
XML Web services have the potential to alter the manner in which each step is performed. Let's start with the last step and work backward.
When you enter a credit card number to pay for a book, the Web site must communicate with a credit card processor to authorize your credit card purchase. The credit card number must be transmitted over the Web, and the purchase must be authorized or declined. All these transactions must be accomplished in real-time. There is no standard way of completing this process. To communicate with each major credit card processor, you must implement different proprietary software.
XML Web services have the potential to standardize the process of authorizing credit cards. Imagine a credit card authorization Web service. The Web service would have an authorization method to accept a credit card number, an expiration date, and a purchase amount. When the method is invoked, it would return either approved or declined.
When purchasing a book, you must select a shipping method. To get a list of shipping options and prices for each option, the Web site must communicate with one or more shipping services. Again, there is no standard way of completing this process. The method for communicating with Federal Express is different than the method for communicating with United Parcel Service.
Now imagine a shipping Web service. You would transmit an origin and destination address to the service, and it would return a list of shipping options with different prices.
Before you can purchase a book, you must first log in to the Web site by entering your username and password. Typically, you must enter new registration information for each site that you use.
Again, imagine a Web service simplifying this process. In this case, it would be a user registration Web service. Whenever you visit a Web site, it could communicate with the user registration Web service to verify your identity. You would pass a username and password to the Web service, and it would return a value indicating whether the username and password combination is valid.
Finally, before you purchase the book, you have to visit several Web sites to find the best price.
XML Web services can even help here. Now imagine a book Web service. You would transmit the title of a book to the service, and it would return the name of the Web site that currently sells the book for the lowest price. Or, better yet, the Web service would automatically communicate with the credit card authorization Web service and automatically buy the book for you at the lowest price.
XML Web Services Facilitate Communication
XML Web services facilitate communication among different Web sites and different applications. Because Web services are built on open standardssuch as HTTP, XML, and SOAPthey enable communication in a platform-independent way.
This last point is important. Because Web services are based on open standards, an ASP.NET Web site can use Web services to communicate with a Web site created on a different platform, such as Java.
You can download the XML and Web services Development Environment from the IBM Web site. This programming environment enables you to build Web services with Java.
Another important application of Web services is communication with applications running on legacy systems. Large companies have a regrettable tendency to employ multiple platforms and applications written in multiple programming languages. Because Web services are built on open standards, you can use them as a common language to bridge the different platforms in an organization.
In the next chapter, "Advanced XML Web Services," for example, you'll learn how to take advantage of a Web services feature called HTML pattern matching , which enables you to perform screen-scraping operations against legacy systems. You can use HTML pattern matching to read information from an application even if the application does not directly support Web services.
Web services not only enable Web sitetoWeb site communication, they also enable applicationtoWeb site and application-to-application communication. For example, you can write a desktop application that communicates with a banking Web service to retrieve your current checking account balance. Or you can use Web services to enable a desktop application running on a computer in Australia to communicate with a desktop application running on a computer in Mexico.
XML Web Services Enable Aggregation
Another important benefit of XML Web services is that they enable you to aggregate content from multiple Web sites and even multiple Web services.
We already discussed the example of aggregating information on the price of books from different Web sites. Another example of aggregation is a meta-search engine. You could query a search Web service, and it could automatically query multiple search engines such as Yahoo! and AltaVista and return the combined search results.
You could build this search Web service even if Yahoo! and AltaVista do not implement Web services themselves . By taking advantage of a feature of Web services called HTML pattern matching, you can retrieve information from any Web site and expose it in your Web service.
Someday soon, all wholesalers might expose their catalog of products as Web services. Retail Web sites could then combine and prune the different catalogs of products to offer a custom selection.