Tutorial: Creating and customizing REST services by using the configuration-based controller command and data bean mapping framework

In this tutorial, you use the configuration-based controller command and data bean mapping framework to add support for creating REST services.

REST services help facilitate the invocation of classic controller commands and the activation of data beans. The REST framework is easy to learn and customize. The framework creates custom REST resource handlers that start controller commands to create, update and delete operations, and activate data beans to retrieve data. To simplify the creation and consumption of REST APIs, WebSphere Commerce provides a utility to create configuration-based controller command and data bean mappings. The utility auto-generates the configuration mapping files and sample handler code for your custom data bean or controller command. It explicitly describes what input is required and what data returns from execution, which reduces the customization effort.

You can create custom handlers to access to your own data beans and controller commands easily. Alternatively, you can use the default REST beans and controller commands to return an augmented set of response data to satisfy your customization requirements.

After completing this tutorial, you should be able to complete the following tasks:
  1. Create a REST handler for mapping the custom data bean and controller command
  2. Customize an existing configuration-based data bean mapping to return more data
The first part of this tutorial uses the sample data bean and controller command that you imported from the sample code. From the sample, create your own mapping configuration files and REST resource handler to make the rest calls to the sample data bean and controller command. The second part of the tutorial takes the default RequisitionListDataBean as an example, and shows how to customize an existing configuration-based data bean mapping to return more data.
Note: This tutorial uses the Derby database.

Time required

Expect this tutorial to take 2 - 3 hours to complete. The tutorial takes longer if you explore concepts that are related to this tutorial.

Skill level

This tutorial is intended for advanced WebSphere Commerce developers responsible for customizing store preview feature. To complete this tutorial, you must be familiar with the following terms and concepts:
  • Web service
  • REST service
  • Widgets definition
  • SQL
  • XML
  • XPath
  • Rational Application Developer
  • JSP/JSPF
  • Java
  • REST mapping command (restClassicSampleGen.bat)

System requirements

Before you begin this tutorial, ensure that you install:

Tutorial resources

Before you begin, ensure that you download and extract any compressed files that contain the required code samples. Place the samples in a temporary directory that is named working_dir, such as C:\restconfig. To complete this tutorial, use the following resources: