Inserting a Flex data service in the MXML file

To pass data to and from the business layer, you must first insert a Flex data service into the MXML file. A Flex data service encapsulates a web service, an HTTP service, or a Java object. The role of a Flex data service is to communicate with the business layer.

To insert a Flex data service in an MXML file:

  1. With the MXML file open in Flex Builder, open the Data panel (Window > Data).
  2. Click the Plus (+) button on the panel and select the type of object in your business layer that will provide or receive the data.



    Web Service inserts a service that lets you access the methods of a SOAP-compliant web service.

    HTTP Service inserts a service that lets you retrieve data from an HTTP address.

    Remote Object inserts a service that lets you access the methods of a Java object.

    After clicking one of the items, a dialog box appears to let you specify the web service, HTTP service, or Java object you want to use.

  3. If you selected Web Service, select a named service from the pop-up menu or enter the URL of a web service's WSDL file in the text box.

    For more information, see Setting the Add Web Service dialog box options.

  4. If you selected HTTP Service, select a named service from the pop-up menu or enter the address of an HTTP data source in the text box.

    For more information, see Setting the Add HTTP Service dialog box options.

  5. If you selected Remote Object, select a named service from the pop-up menu or enter the location of the Java object or Flash Remoting service in the text box.

    For more information, see Setting the Add Remote Object dialog box options.

After closing the dialog box, the web service, HTTP service, or remote object appears in the Data panel indicating that a reference to it has been inserted into the MXML file and that you can bind it to a component or a data model in the file. For instructions, see Binding a Flex data service to an object.

A Flex web service is easier to use than the other Flex data services because you can visually bind to the web service's results or parameters without knowing them in advance--Flex Builder retrieves and displays the schema for you. Flex Builder does not retrieve and display the schema of HTTP services and remote objects. You must know the schema of these objects in advance to recreate it in your code (for visual binding), or to write the binding expression yourself.

Related topics