Create Rich Web Apps with AJAX: Listing 2: C#, Call an external Web Service
Wrapping external Web service calls with a local Web service is straightforward. This code demonstrates how a local Web service can act as the middle-man between an AJAX-enabled page and an external Web service.
namespace GolfClubShack
{
[ScriptService]
[WebService(Namespace = "http://xmlforasp.net/")]
[WebServiceBinding(ConformsTo =
WsiProfiles.BasicProfile1_1)]
public class AmazonService :
System.Web.Services.WebService
{
public AmazonService()
{
// Uncomment the following line if using designed
// components
//InitializeComponent();
}
[WebMethod]
public Book[] GetBooks(string searchText,string page)
{
AmazonSearch search = new AmazonSearch();
return search.SearchBooks(searchText, page, 5);
}
}
}