RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Consuming External Web Services with Microsoft Atlas

To consume external Web services in Atlas, you build a server-based Web service proxy to the service. The good news is that you can leverage Visual Studio and Atlas features to handle most of the work.

hile AJAX is the current rage for building interactive browser-based client applications, the action on the server side has focused on Web services. In fact, Web services have become the de-facto standard for exposing business functions at the server level. Given these conditions, a central development question becomes: How do you enable your AJAX-based applications to communicate with Web services? This article explores how you can use Microsoft Atlas (recently renamed to ASP.NET AJAX) to achieve just that.

To follow along, you'll need Visual Studio 2005 and Microsoft Atlas downloaded and installed. If you don't have Visual Studio 2005 installed, you can download a free Visual Studio Express version. This article explains how to interact with Web services through Atlas using an application I've called "ZipCodeRUs." The ZipCodeRUs application retrieves detailed ZIP code information such as the names of cities, counties, and their latitude, longitude, area code, etc. for up to three ZIP codes entered by the user. It relies on a free and publicly available Web service at tilisoft.com to retrieve the information. The ZipCodeRUs application illustrates Atlas's Web service prowess in two ways:

  • It demonstrates Atlas's JavaScript proxies asynchronously communicating with an ASP.NET (.asmx) Web service (which functions simply as a conduit to the external Tilisoft ZIP code Web service).
  • It demonstrates Atlas's capability to batch web service calls from JavaScript client to server
Author's Note: Microsoft Atlas also provides the ability to create XML-based declarative bridges to external Web services without having to create conduit services; however, this article does not cover this bridge feature.

Figure 1. Creating a New Atlas Web Application: When you install the Microsoft Atlas CTP, you'll find a new project template called "'Atlas' Web Site" in the "New Web Site" dialog.
The full downloadable code for the ZipCodeRUs application accompanies this article.

Getting Started with Atlas Web Services
In Microsoft Visual Studio, create a new Web application for ZipCodeRUs by selecting the "Atlas Web Site" template as shown in Figure 1. The "Atlas Web Site" template is installed when you download and install the Microsoft Atlas CTP. The "Atlas Web Site" template creates a Web site that includes a reference to the Microsoft.Web.Atlas.dll and a Web.config file that preconfigures the Web site for using Atlas.

If you need to add Atlas capabilities to an existing ASP.NET application you can find the procedure in this Atlas web site in the section titled "Adding Atlas features to an existing ASP.NET application."

One problem with AJAX applications that rely on external Web services (services that aren't provided at the same domain as the application itself) is that you can't use JavaScript to access such Web services directly—browsers will prevent all such "cross-scripting" access. For security reasons, browsers allow JavaScript on a Web page to access only Web sites from the domain where the page originated. To solve this problem, the Atlas JavaScript client relies on .asmx files (ASP.NET Web services) to create runtime JavaScript proxies. In other words, the client calls a Web service exposed by the home domain, which in turn calls the external Web service, then simply passes the response back to the client.

Therefore, before you can call an external Web service from your Atlas client, you first need to create a strongly typed proxy. For this example, I've built a C# proxy for the ZipCode Web service and an ASP.NET Web service that serves as a conduit.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date