Chapter 18. Using Remote Web Services

Chapter 5 and Chapter 17 discussed consuming ASP.NET web services with ASP.NET AJAX. The XMLHttpRequest object that fuels all Ajax applications runs in a restricted environment and is forbidden access to anything outside the current domain. If you need data from a remote web service (one that is on a different server), there is only one solution: create a proxy on your server and then call this proxy from your JavaScript code. This in turn allows creating mashups. Mashups are web applications that use data from different sources to “mix ‘n mash” them into something new. This chapter shows you how to make remote web services data accessible to JavaScript. From there you can use JavaScript to combine various external sources into something new.

The ASP.NET AJAX Futures release supports proxy implementation for such web services calls through a technology referred to as a web service bridge. In the following sections, we will create pages that receive data from two of the most popular commercial web services, the Google search web service and the Amazon e-commerce web service. The techniques shown here can easily be adapted to any other SOAP web service.

The secret behind this rests in a new file extension that the ASP.NET AJAX Futures release web site template registers in Web.config: .asbx. Files with this extension can contain XML markup that provides information about a local (server-based) proxy class for a web service. The web page’s JavaScript ...

Get Programming ASP.NET AJAX 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.