Calling an External Web Service

Let’s start simple. We create a Quotation web service that randomly returns a quotation from a list of quotations. Next, we create an AJAX page that contains a button. When you click the button, a random quotation displays in a <span> tag (see Figure 40.4).

Figure 40.4. Retrieving a random quotation from the server.

image

The first step is to create the web service, which is contained in Listing 40.5.

Listing 40.5. QuotationService.asmx

images

You create the file in Listing 40.5 by selecting Website, Add New Item and choosing ...

Get ASP.NET 4 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.