2. Configuring the return data
You need to configure the
type of data that the service will return so that Flex can properly
process it. Once you have completed the steps in the previous section,
the Data/Services view will display the getAllMagazines operation.
Select the getAllMagazines operation.
Right-click the getAllMagazines operation and choose Configure Return Type from the context menu. You can also click the Configure Return Type button at the top of the Data/Services view. (see Figure 10).
In the Configure Return Type dialog box, ensure that the option Auto-detect return type from sample data is selected (see Figure 11).
Click
Next. Flash Builder needs to call, or invoke, the service to determine
what kind of data will be returned. Some services will require that a
parameter be sent to them; for example, a search operation would need a
search string. The service used in these examples, however, simply
returns all data, so you do not need to provide a parameter.
Flash Builder will therefore invoke the service and return a list of the data being returned.
In
this example, the service returns a list of magazines and information
about them. ActionScript can store multiple values in a single variable,
as is needed in this case, in an array. Flash Builder will display a dialog box stating that it cannot automatically determine the property type.
Enter a name for the array, such as MagazinesData (see Figure 12).
The name of the service and
the name of the data type cannot be the same. In this example, the
service name is Magazines, so the data type cannot be Magazines. |