View comments | RSS feed

WebService class

Availability

Flash Media Server 2.

Description

You can use the WebService class to create and access a WSDL/SOAP web service. There are several classes that comprise the Flash Media Server web services feature: WebService class, SOAPFault class, SOAPCall class, and Log class.

NOTE

 

The WebService class is not able to retrieve complex data or an array returned by a web service. Also, the WebService class does not support security features.

The following steps outline the process of creating and accessing a web service.

To create and access a web service:

  1. Prepare the WSDL location:
    var wsdlURI = "http://www.flash-db.com/services/ws/companyInfo.wsdl";
    
  2. Instantiate the web service object using the WSDL location:
    stockService = new WebService(wsdlURI);
    
  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.

Constructor for the WebService class

Availability

Flash Media Server 2.

Usage

new WebService(wsdlURI)

Parameters

wsdlURL A string specifying the URL of a WSDL URL.

Returns

A WebService object.

Description

Constructor; creates a new WebService object. You must use the constructor to create a WebService object before you call any of the WebService class methods.

Example

The following example prepares the WSDL location and passes it to the WebService constructor to create a new WebService object, stockService:

var wsdlURI = "http://www.flash-db.com/services/ws/companyInfo.wsdl";
stockService = new WebService(wsdlURI);

Comments


No screen name said on Apr 4, 2007 at 1:55 AM :
To use the WebServices class, you need to import it into your application first. Otherwise you get an error. To import it:

//Load the webservices class
load("webservices/WebServices.asc");

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/fms/2/docs/00000796.html