Turning Web Sites into Web Services
Pages: 1, 2, 3, 4

After you've chosen where the Robot Library is located, you may, as in this case, have to specify further information about the library (for example, the library's URL). In the example, we specify the location of the robot library file in the local file system (see Figure 8).

Selecting the Robot Library URL
Figure 8. Selecting the Robot Library URL

As soon as you specify the full location of the robots, the map table shows the robot in the library. The purpose of the map is to define a mapping between a robot and a method on the control. If a mapping in the list exists, then calling the method results in a call to the given robot. The aim is to define mappings for all three robots such that the control has a method for performing each of the three operations that the robot performs: search, add, and delete. You add a new mapping by right-clicking in the Mapping column next to a robot and selecting the option New… as Figure 9 shows.

Creating a new mapping
Figure 9. Creating a new mapping

This step launches the Map Editor (see Figure 10). The Map Editor suggests a default mapping, which contains a signature and a return type for the method, a mapping from input parameters of the method to the attributes of the input objects to the robot, and a mapping from the output object of the robot to the result of the method. In the case of the add robot, there is one input object called PhoneUpdate and it has two attributes: name and number. The editor suggests a mapping where the two parameters of the method map directly to the attributes of the PhoneUpdate object. This seems like a sensible mapping for the input, so you will keep this.

The map editor
Figure 10. The map editor

The result mapping for the output, however, is not what you want. This result mapping for the output specifies that all objects will be returned in a list. For the add robot you know that one and only one object will be returned and that this object is a PhoneStatus object. So you may as well choose a result mapping that returns only the first PhoneStatus object. The Java object PhoneStatus is a public static inner class in the Phone interface defined in the generated JCX-file. Figure 11 shows how to select a result mapping.

Selecting the result mapping
Figure 11. Selecting the result mapping

Pages: 1, 2, 3, 4

Next Page »