Adding RESTful Services
You can use RESTful services as data sources for a mobile application. An application can execute RESTful services to obtain data to display in the application’s user interface. Because RESTful services typically return multiple data elements, it is common to use a
ListView object to display the data you obtain from a RESTful service. For more information, see
Using a Content Provider to Populate a
ListView.
To add RESTful services
2. In the Model section of the Outline Editor, expand the project so that you view the Services container node.
If the model does not have a Services container node, add one by right-clicking the root application and selecting New Child > Services.
3. Right-click the Services node and select New Child > Resources.
Note: | You can also drag the Resources object from the palette of the Outline Editor to the Services node. In the palette, you can find this object when clicking the header-type node RESTful Services. In this case, a wizard appears in which you can specify the details for the new node. All additionally required child nodes as described below are then automatically added to the Model section. You do not have to add them manually. For more information, see Using the Palette to Add Objects to the
Mobile Project. |
4. Select the Resources node, and in the Properties section of the Outline Editor set the properties for the Resources node. For more information, see Resources Properties. 5. Right-click the Resources node and select New Child > Resource.
6. Select the Resource node, and in the Properties section of the Outline Editor set the properties for the Resource node. For more information, see Resource Properties 7. Right-click the Resource node and select one of the following:
New Child > Method to specify the service you want to use. The mobile application queries the RESTful service by calling the method you specify.
New Child > Resource if you want to add additional
Resource objects to specify subpaths. If you add another
Resource node, repeat the previous step to specify the properties for the
Resource node and this step to add a child node.
8. When you add a Method child node, select the node, and in the Properties section of the Outline Editor set the properties for the Method node. For more information, see Method Properties. Note: | Mobile Development automatically adds two child nodes for the Method node. The child nodes are Request and Response. |
9. Select the Request node, and in the Properties section of the Outline Editor set the properties for the Request node. For more information, see Request Properties. 10. If the RESTful service requires input parameters, perform the following steps for each input parameter:
a. Right-click the Request node and select New Child > Parameter.
b. Select the Parameter node, and in the Properties section of the Outline Editor set the properties for the Parameter node. For more information, see Parameter Properties. 11. Select the Response node, and in the Properties section of the Outline Editor set the properties for the Response node. For more information, see Response Properties. Tip: | To update the Java classes that Mobile Development generates for the project so that your changes are represented in the generated sources, save the project and regenerate sources. For instructions, see If this is the first service you added, use Generate Source Code > Application Model and API to generate the com.software.mobile.runtime.rest package in the src-api folder. |
Related Topics