As stated earlier in the tutorial, an advantage to writing application functionality as a web service is that different front ends can consume it. For example, you are now going to see how to use Flash MX 2004 to consume the web service you just built.
In exercise 5, we're going to use Flash to consume the web service you just created. First, we're going to create a new Flash document, then point to the web service using the Web Services panel. Then, we're going to place a WebServiceConnector component on the Stage and associate it with your web service. Even if you have never used Flash before, you can easily follow along because you accomplish the entire process by dragging, dropping, and selecting choices from panels (no ActionScript required). Here we go:
The Define Web Services dialog box appears, as follows:
Figure 5. The Define Web Services dialog box that specifies the web service you just created
In the Properties panel (also called the Property inspector), replace <Instance Name> in the input box with wscBikeParts. Press Enter.
Figure 6. Changing the component name in the Property inspector
Click in the Value column for the operation, and select the returnquery function:
Figure 7. Specifying settings for the WebServiceConnector component
Click the DataGrid and resize the it as shown here:
Figure 8. Resizing the datagrid with the Free Transform Tool
In the Add Binding dialog box, click dataProvider : Array since the data from the web service will be returned as an array.
Figure 9. Adding a binding to the WebServiceConnector component
In the Bound To dialog box that appears, click WebServiceConnector for the Component path, and then click results : Array for the Schema location. This connects the web service data to the DataGrid:
Figure 10. Binding the result set
Click the wscBikeParts WebServicesConnector. This triggers the WebServiceConnector to go and retrieve data from the web service when the Flash application starts.
Figure 11. Selecting the wscBikeParts WebServiceConnector component to trigger the data source