User Guide
WebService class 163
3. (Optional) Handle the WSDL parsing and web service instantiation event through the
WebService.onLoad handler:
// Handle the WSDL loading event.
stockService.onLoad = function(wsdl){
wsdlField.text = wsdl;
}
4.
(Optional) Handle the fault if the WSDL doesn’t load:
// If the WSDL fails to load the onFault event is fired.
stockService.onFault = function(fault){
wsdlField.text = fault.faultstring;
}
5.
(Optional) Set the SOAP headers:
// If headers are required they are added as follows:
var myHeader = new XML(headerSource);
stockService.addHeader(myHeader);
6.
Invoke a web service operation:
// Method invocations return an asynchronous callback.
callback = stockService.doCompanyInfo("anyuser", "anypassword", "MACR");
// NOTE: callback is undefined if the service itself is not created
// (and service.onFault is also invoked).
7.
Handle either the output or the error fault returned from the invocation:
// Handle a successful result.
callback.onResult = function(result){
// Receive the SOAP output, which in this case
// is deserialized as a struct (ActionScript object).
stock.companyInfo = result;
}
// Handle an error result.
callback.onFault = function(fault){
// Catch the SOAP fault and handle it
// according to this app's requirements.
stock.companyInfo = fault.faultstring;
}
Event handler summary for the WebService class
Property Description
WebService.onFault Invoked when an error occurs during WSDL parsing.
WebService.onLoad Invoked when the web service has successfully loaded and parsed
its WSDL file.