↑
Main Page
Using the SOAP methods
Using the SOAP methods
Mozilla provides a very large amount of SOAP functionality, but because this is an older API, only the
most common usage is discussed here.
The basis of Mozilla’s SOAP functionality is the
SOAPCall
object. This object embodies the entire Web
service request and response. The
SOAPCall
object is created just like any other object:
var oSoapCall = new SOAPCall();
The next step is to set the location of the Web service by assigning it to the
SOAPCall
object’s
transportURI
property:
oSoapCall.transportURI = “http://address_of_service”;
This address is
not
the address of the WSDL, as it is in Internet Explorer. Instead, this is the actual URL
for the Web service itself (as defined in the WSDL element
<soap:address location=”http://
address_of_service” />
element).
After setting the location of the service, you create an array to handle the SOAP parameters. This is just a
regular array filled with
SOAPParameter
objects. The
SOAPParameter
constructor takes two arguments:
the value of the parameter, and the name (in that order). The array can contain any number of parame-
ters and is created like this:
var arrParams = new Array;
arrParams[0] = new SOAPParameter(“value”, “name”);
Next you create the
SOAPCall
object’s
encode()
method on the array, which encodes the parameters
for proper transmission. For this method, you need to know the name of the operation and the target
namespace:
oSOAPCall.encode(0, “operation_name”, “target_namespace”, 0, null,
arrParams.length, arrParams);
The arguments are:
?
The version of SOAP used:
?
0 for version 1.1
?
1 for version 1.2
?
65535 if the version is unknown
Note that you cannot assume that users have their browsers set up to allow the
UniversalBrowserRead privilege. If you plan on using this method of Web service
invocation, you must create a signed script (explained more fully in Chapter 19,
“Deployment Issues”). Also note that this is Mozilla-specific code that does not run
properly in IE, so it is important to do a browser detect before requesting a signature
for your script.
518
Chapter 17
20_579088 ch17.qxd 3/28/05 11:42 AM Page 518
Free JavaScript Editor
Ajax Editor
©
→