Chapter 8: Consuming Web Services


It seems almost perverse that we’ve spent the last seven chapters talking about how to create Web services but we’ve virtually ignored the subject of most interest to end users—how to consume and make use of Web services. We’ve analyzed each section of the pipeline, from the creation of the class to the method and format of the transmission of the Web service—but without the ability to harvest information at the other end, all these elements are as good as useless. In places, we’ve been so wrapped up with the method of delivering information fromjmnh the Web service that we’ve sometimes either provided client code without any guidance for what it does or omitted client code altogether from our sample Web methods. It’s time to remedy the situation and talk about Web services from the point of view of consumption.

Types of Clients

To consume a Web service, you need a client. The client provides the interface through which a user can connect to a Web service. The client can take a variety of forms. With a small, dedicated Web client, a user might run an application (such as a stock ticker or an Amazon sales position ticker) and specify that the client application connect once every 15 minutes for an update. Or the client might be something less obtrusive, such as an antivirus program that automatically runs on your taskbar, periodically checking its parent site for the latest updates. Or the client might even be the Windows update mechanism itself.

Of course, not all clients have to be executable applications—they can just as easily be Web Forms, such as those that return maps when supplied with a ZIP or postal code, or a set of news channels downloaded onto a browser on a personal digital assistant (PDA) with the most relevant headlines. Clients don’t even have to be restricted to using Web Forms or to being Web browser–based applications. Applications such as multimedia or MP3 players might use Web services as a sideline to the main functionality—say, to download extra information about the media being played. Another example might be a flight simulator application that connects to the Internet to download the latest weather conditions so users can experience within the simulation the actual weather patterns outside.

Any application capable of receiving XML across HTTP can consume a Web service. That means the role of Web services can be much broader than you might initially assume. Beyond applications that connect to the Web, download information, and then close down, Web services can improve the usefulness of any client and the overall richness of the user experience. In fact, many clients exist just to provide an interface with already existing Web services; users might never have to build a Web service for themselves.

We’ll start by looking at the existing model that .NET uses for Web service consumption. Then we’ll examine how a client can discover a Web service and look at how to build different types of clients.




Programming Microsoft. NET XML Web Services
Programming MicrosoftВ® .NET XML Web Services (Pro-Developer)
ISBN: 0735619123
EAN: 2147483647
Year: 2005
Pages: 172

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