Main Page

Using WSDL proxies

Using WSDL proxies
As you can tell, using the Mozilla SOAP functionality is quite a process and requires a bit of research
(looking at the WSDL file) to use properly. Additionally, the hassle of signing a script for cross-domain
communication isn’t something developers really want to deal with. Being a forward-looking organiza-
tion, Mozilla realized this and came up with an answer: WSDL proxies.
The basic idea of WSDL proxies is that SOAP requests should be allowed to go through provided that
they are valid. In the case of Web services, the server is only vulnerable insofar as it’s vulnerable to any
Web service consumer. Presumably, each server publishes only functionality that can’t hurt itself. With
this in mind, it was decided that if the Web service request could be flagged as such, it should be allowed
to communicate with other servers. This resulted in the WSDL proxies introduced in Mozilla 1.4.
A WSDL proxy is essentially an object that represents a Web service by creating operations as methods
of the proxy. You can specify the methods to make calls either synchronously or asynchronously, but all
methods of a proxy must use the same synchronicity (all are synchronous or all are asynchronous — you
can’t pick and choose).
Unfortunately, using WSDL proxies isn’t as straightforward as using the low-level SOAP functionality or
the Microsoft
To begin, you create a
var oFactory = new WebServiceProxyFactory();
The factory’s only implemented method (there are others in the documentation) is
which creates a proxy asynchronously, so as not to interfere with regular JavaScript processing. The
method accepts the following arguments:
The location of the WSDL file
The port name
A qualifier, which is always set to an empty string (this argument is only used when the object
is used at the C++ level of Mozilla)
A Boolean value indicating whether the methods of the created proxy should be called
A callback object whose methods are notified when certain events occur during proxy creation
That last argument, the callback object, must have two methods:
, which is called when the
proxy has been loaded completely, and
, which is called if an error occurs during proxy cre-
ation. Each method accepts one argument. The
method is passed the created proxy object;
method is passed an error message.
Typically, the callback object is created using object literal notation, such as the following:
var oCallbackObject = {
onLoad: function (oCreatedProxy) {
Chapter 17
20_579088 ch17.qxd 3/28/05 11:42 AM Page 522

JavaScript EditorFree JavaScript Editor     Ajax Editor