Calling the data service

If you create a binding that passes data to, or retrieves data from, a data service, then you must create an event handler that calls the data service. A component can call a data service such as a web service only in response to an event. Otherwise, the data service is never invoked. You can create this event handler rapidly with Flex Builder.

To create an event handler to call a data service:

  1. Make sure your MXML file contains a binding to a data service such as an web service, an HTTP service, or a remote object.

    The binding must appear in the Bindings panel (Window > Bindings). For more information, see Working with Flex data services.

  2. In Flex Builder, select the component that will generate the event to invoke the data service.

    For example, you can select a Button component for users to click.

  3. In the Events panel of the Tag Inspector (Window > Tag Inspector), click the field next to the event that will trigger the service call.

    A lightning bolt icon appears next to the field.

  4. Click the lightning bolt icon.

    The Select Source for send() dialog box appears.

  5. Specify the data service to invoke.

    For example, if you want to invoke a weather-related web service, select the web service in the left pane (you must define the web service in the Data panel first) and then select the operation to invoke in the right pane.



  6. Click OK to create the event handler.

Related topics