|
|
Using the Mozilla SOAP API Constructing the SOAP MessageYou create a SOAP message just as you would an array or image object with scripting. A number of SOAP-related objects are available, but for now you'll only need to worry about these four:
The Identifying Service MethodsSo what methods can you call on a given Web service? Usually a service will provide a WSDL (Web Service Description Language, yet another XML schema) file describing the available methods and the parameters required for calling them. A smart SOAP client will be able to parse this file and automatically generate the interfaces it needs to communicate with the service. Mozilla is smart, but not quite that smart - its WSDL interface is still being developed. So for now we're stuck reading the WSDL file ourselves to learn what a service has to offer. A tutorial on WSDL could easily fill another article, so I'm going to skip the gory details and only point to the relevant parts as needed throughout this article. The WSDL file for the Google Web API identifies three methods:
The
Enabling Security PrivilegesBefore you create a SOAP message, you need to allow the user to grant "UniversalBrowserRead" permissions to the script so it can make the call to the remote service. To do this, you'll need to use the Privilege Manager, part of the original Netscape product and the Mozilla code base.
The above code must go inside the JavaScript function or code block responsible for initiating the SOAP call, and must come before the call itself. When this code executes, users are presented with a prompt that asks them to grant or deny the privilege:
This should happen every time the Remember that this privilege can only be granted to a signed script or one running from the local machine. Otherwise, the code will produce an "enablePrivilege not granted" error and the SOAP call will not be made. |
|
|
|
|
||||||||