Main Page


onError: function (sMessage) {
This object is passed into the
method as in the following:
oFactory.createProxyAsync(“wsdl_location”, “port_name”, “”, true, oCallbackObject);
method should always be called within a
statement because it
throws an error if the method fails for any reason.
After this method is called, a new thread is started to load the WSDL proxy. When loaded, the
method is called and the new proxy is passed in. If you are only making a single Web service call, you
may want to have this method call the specific operation. Otherwise, you’ll probably want to store a ref-
erence to the proxy, such as this one, for later use:
var oProxy = null;
var oCallbackObject = {
onLoad: function (oCreatedProxy) {
oProxy = oCreatedProxy;
onError: function (sMessage) {
In this example, a global variable named
is created that stores the created proxy. In the
method, the created proxy is assigned into
so it can be accessed in other functions.
Even though you can specify whether the proxy operations are called synchronously or asynchronously,
the synchronous calls don’t always work. It’s always best to use asynchronous calls.
To call an operation asynchronously requires yet another callback object. This object must have a call-
back method for each operation you intend to call. The name of the callback method is always the
name of the operation followed by
(for instance, the callback method for
is called
). This method receives as its arguments the response data from the Web service call.
To understand this better, it’s best to take a look at an example.
This example once again uses the Temperature Service. The important pieces of information are the
WSDL file location and the port name. Here are the global variables:
var oProxy = null;
var sWSDL = “”;
var sPort = “TemperaturePort”;
Next, you need a callback object for creation of the proxy. This simply assigns the created proxy to the
variable and assigns a callback object for the operations using the
Web Services
20_579088 ch17.qxd 3/28/05 11:42 AM Page 523

JavaScript EditorFree JavaScript Editor     Ajax Editor