ActionScript 2.0 Components Language Reference |
|
|
|
| Web service classes > Constructor for the WebService class | |||
Flash Player 6 (6.0.79.0).
Flash MX Professional 2004.
myWebServiceObject= new WebService(wsdlURI[,logObject]);
wsdlURI The URI of the web service WSDL file.
logObject An optional parameter specifying the name of the Log object for this web service. If this parameter is used, the Log object must be created first. For more information, see Log class.
Nothing.
Constructor function; creates a WebService object. When you call new WebService(), you provide a WSDL URL, and Flash Player returns a WebService object. The constructor can optionally accept a proxy URI and a Log object.
If you want, you can use two callbacks for the WebService object. Flash Player calls webServiceObject.onLoad when it finishes parsing the WSDL file and the object is complete. This is a good place to put code you want to execute only after the WSDL file has been completely parsed. For example, you might choose to put your first web service method call in this function.
Flash Player calls webServiceObject.onFault when an error occurs in finding or parsing the WSDL file. This is a good place to put debugging code and code that tells users that the server is unavailable, that they should try again later, or similar information. For more information, see the individual entries for these functions.
Invoking a web service operation You invoke a web service operation as a method directly available on the web service. For example, if your web service has the method getCompanyInfo(tickerSymbol), you would invoke the method in the following manner:
myPendingCallObject = myWebServiceObject.getCompanyInfo(tickerSymbol);
In this example, the callback object is named myPendingCallObject. All method invocations are asynchronous, and return a callback object of type PendingCall. (Asynchronous means that the results of the web service call are not available immediately.)
Consider the following call:
x = stockService.getQuote("macr");
When you make this call, the object x is not the result of getQuote; it's a PendingCall object. The actual results are only available later, when the web service operation completes. Your ActionScript code is notified by a call to the onResult callback function.
Handling the PendingCall object This callback object is a PendingCall object that you use for handling the results and errors from the web service method that was called (see PendingCall class). Here is an example:
MyPendingCallObject = myWebServiceObject.myMethodName(param1,...,paramN); MyPendingCallObject.onResult = function(result) { OutputField.text = result } MyPendingCallObject.onFault = function(fault) { DebugField.text = fault.faultCode + "," + fault.faultstring; // Add code to handle any faults, for example, by telling the // user that the server isn't available or to contact technical // support. }
|
|
|
|