The Mozilla browsers support their own ways of calling Web Services. The JavaScript SOAPCall class can take care of creating the SOAP request. After instantiating the class, you have to set a couple of properties: the SOAP action (a SOAP header field, often the namespace of the Web Service plus the method name) and the absolute URI (including the name of the server) of the Web Service: var soapcall = new SOAPCall(); soapcall.actionURI = "http://javascript.phrasebook.org/randomNumber"; soapcall.transportURI = "http://localhost/js/webservice.php"; Next, you create an array of all parameters you want to use in the Web Service call, by instantiating the SOAPParameter class: var parameters = [ new SOAPParameter(1, "lower"), new SOAPParameter(49, "upper") ]; Then, the encode() method prepares the Web Service call. The following parameters are expected:
The asyncInvoke() method actually calls the Web Service; you can provide a callback function that gets executed when the data comes back from the Web Service. This is an XML document, so you have to use the DOM to access the important information. The following code usually works: function callbackFunction(result) { var returnData = result.body.firstChild.firstChild.firstChild.data; } Here is the complete code: Calling a Web Service from Mozilla (webservice-mozilla-php.html)
Note Again, do note that you may have to change the URL for the Web Service call so that it fits your system. |