How the z/VSE Host Can Act As the REST Server

Figure 1 shows how REST can be used in a CICS TS environment when the z/VSE host acts as the REST server that provides RESTful web services.

Figure 1. Involved modules when z/VSE acts as a REST server
An explanation of this figure is provided in the surrounding text.

For z/VSE as a RESTful web service provider (server),the HTTP request is received by CICS Web Support (CWS). The URL to start a z/VSE provided RESTful web service must look as follows:

http://host:port/cics/CWBA/IESRESTS/userprog[/resource-uri][?query-string][#fragment]

This URL tells CICS Web Support to call program IESRESTS (which is the server part of the z/VSE REST engine) under the CICS supplied transaction CWBA. The name of the user-provided program, which implements the RESTful web service, is specified as part of the URL as shown above. The REST engine performs data translation based on the content type, as well as parsing (for XML or JSON type data). The REST engine then calls the user-provided program and passes the HTTP request type (GET, PUT, POST, DELETE, etc), the resource-uri (if specified), query string containing URL parameters (if specified), additional HTTP headers (if specified), the content type of the payload, and the payload itself (as buffer in memory or as parsed XML- or JSON-tree). The user-provided program uses the passed information and performs the desired action and finally returns back to the REST engine. It passes back the response code, response content type and response payload. The REST engine then performs data translation based on the response content type, as well as XML or JSON data generation and sends the response back through CICS Web Support to the REST client on the remote system.

IBM provided REST Server example COBRESTS.c

The IBM provided REST server example COMRESTS.c illustrates how to use the z/VSE REST engine to provide a RESTful web service. The example is provided as part of the VSE Connector Client. See section Installing the VSE Connector Client for how to install the VSE Connector Client. In the sample directory of your VSE Connector Client installation you will also find a job to compile and link COBRESTS.c (job COBRESTS.job).