O'Reilly logo

Programming Atlas by Christian Wenz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Consuming Web Services with JavaScript

The automatic mechanisms that Atlas provides for accessing web services are really easy to use because they take care of most of the work. However, there are situations when these mechanisms do not work. For instance, imagine that you have to call a (same domain) web service that is not written in .NET, but in another server-side technology such as PHP or Java. Or imagine that you cannot use Atlas for some reason (for instance, due to company policies regarding third-party modules or disagreement with the 331icense). This book is not limited to covering how to use Atlas to write Ajax-empowered ASP.NET applications; it also discusses how to use the underlying technologies involved. So this section covers alternative ways to call remote web services from JavaScript.

Before we go into detail, you have to remember once again that the security model of JavaScript forbids cross-domain scripting. That means that you cannot access remote sites using JavaScript (implicitly using XMLHttpRequest). If you need to call a remote web service, you will have to revert to the Atlas web service bridge covered in the preceding section.

There are two possible ways to call a web service programmatically using JavaScript. You can either bet on XMLHttpRequest, or write a suitable SOAP HTTP request and then evaluate the data returned from the server. This is quite complicated and very error-prone. A much better approach is to use built-in technology or official add-ons ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required