Representational State Transfer (REST) services

Representational State Transfer (REST) is a lightweight framework for designing applications that use HTTP to make calls. REST uses HTTP to perform the Create, Read, Update, and Delete (CRUD) operations between client and server. Applications interact with the services by using HTTP, POST, PUT, GET, and DELETE operations. WebSphere Commerce uses Representational State Transfer (REST) services to provide a framework that can be used to develop RESTful applications on several platforms. These platforms can include web, mobile, kiosks, and social applications.

Comparatively, REST can perform the same functions as the Simple Object Access Protocol (SOAP) and Web Services Description Language (WSDL).

REST is platform and language independent, and because it is built on HTTP, is compatible in environments behind firewalls. REST can use secure connections over HTTPS to take advantage of HTTPS security features such as encryption or username and password tokens.

REST calls include all the information required to return results (state transfer), eliminating the need for cookies when we are using REST services in the storefront. REST services help facilitate the invocation of classic controller commands and the activation of data beans. They aim to provide a framework that is easy to learn and customize. The framework lets you create custom REST resource handlers that invoke controller commands to perform add, update and delete operations, or activate data beans to retrieve data.Important: It is not recommended to use the REST classic programming framework to invoke controller commands that change session information. For example, the user ID. Sample controller commands that alter session information are the LogonCmd and LogoffCmd commands.

We can create REST services using the configuration-based controller command and data bean mapping framework. It helps create REST services and automates mappings using the restClassicSampleGen utility, and allows the activation of data beans or the running of controller commands using REST services.


REST services characteristics

The following list summarizes the key characteristics of the REST architecture:


REST services abstraction

The following diagram illustrates the various components of the REST services abstraction:

Where:


REST services in WebSphere Commerce

RESTful applications can be developed on several platforms for WebSphere Commerce. The following diagram illustrates the various REST client platforms and servers:

Where:


REST services interaction

The following diagram shows the REST services interaction flow:

Where:Authentication Services:

  1. Authenticates a registered user or creates a guest user.

  2. Invokes a Member service request.

  3. Returns an authenticated identity.

  4. Creates authentication tokens.

  5. Returns the WCToken and WCTrustedToken tokens.

  6. Generates a response in the requested format.

  7. Returns a response object to the client.

Business Services:

  1. Makes a service request with security tokens.

  2. Invokes request handlers and BCS.

  3. Verifies security tokens by runtime.

  4. Maps JAX-RS resources to WebSphere Commerce component services, generates, and sends service requests.

  5. Returns the result as a Service Data Object (SDO).

  6. Maps the SDO to the requested data format.

  7. Returns the response object to the client.

Command and Data Bean Services:

  1. Makes a service request with security tokens.

  2. Invokes request handlers and BCS.

  3. Verifies security tokens by runtime.

  4. Maps JAX-RS resources to:

    • WebSphere Commerce controller commands to perform the command.

    • WebSphere Commerce data beans to perform data bean activation.

  5. Returns the results in:

    • TypedProperty by controller command.

    • TypedProperty by resource handler.

  6. Returns the response object to the client.

    JSON and XML response formats are supported by default.


Limitations

Consider the following limitations when we are working with the WebSphere Commerce REST API:


WebSphere Commerce REST API

WebSphere Commerce REST services are JAX-RS REST services that are built on top of Apache Wink. The implementation classes contain JAX-RS annotations such as @Path, @Produces, @Consumes, @QueryParam, and @PathParam.


Related concepts
Location-based services
WebSphere Commerce Storefront REST API