Creating the CICS TG Mobile Demo
Andrew Smithson 060000Q8TA Comments (4) Visits (6333)
In our recent blog post about the new mobile support in CICS Transaction Gateway (CICS TG) we discussed how easy it was to create a new application to access existing CICS resources. In this blog post I'll show you how I put together a sample application which makes use of the programs and data provided by the the GENAPP support pac.
The architecture of the completed solution looks like
Setting up CICS TG
Configuring the Gateway daemon for http requests
To allow the Gateway daemon to receive and process http requests I added the following configuration to the
This tells the Gateway daemon that I want it to listen for http requests on port 26682. To check this configuration is correct, the following log message is output during the Gateway daemon initialization.
Creating the JSON web services
The application makes use of two web services, one to get a list of all the customers and the other to get all the details for a particular customer.
Create the web service bind files
The critical piece of configuration for each web service is the web services bind (WSBind) file. This file contains the information required to perform the transformation between a JSON object and a CICS application payload that can be passed to the CICS program.
To generate the bind files I made use of the web services assistant shipped with CICS TG which can generate a bind file from either the language structure definition of the data as the CICS program uses it or from a json schema describing the data as the web service client provides it.
The CICS program for retrieving a customer's details already existed so the bind file was generated from the COBOL source describing the COMMAREA structure. The parameters passed to the assistant for this were:
As well as the bind file this operation produces two json schema files which describe the JSON objects passed to and from this web service. This information is then used by the mobile application to ensure the call to the web service is correct.
Unfortunately there was no existing program to retrieve all the customers in the customer database so a new program had to be created. As this would be a brand new program I could start from the mobile application and decide how the information should be passed back and forth. To start I created a JSON schema to describe how the data would be formatted:
and then used the web services assistant to generate the high level language structures:
which produced the bind file and the language structure elements. Prefering to code in C rather than COBOL, I chose to produce C header files to describe the data format in the new program.
Configure the CICS Transaction Gateway
Once the WSBind files had been created I needed to configure the Gateway daemon to make the web services available. Each web service requires a new section in the configuration file, so for the demo the configuration file contains the following:
The configuration options have the following affect
When the Gateway daemon is started the following log messages are written which shows that the web services have been successfully created:
Building the mobile application
In order to easily build a mobile application that could be deployed on a variety of platforms I decided to make use of IBM Worklight to build the application as this provides an easy way to do this. There are two parts to the application, a Worklight adapter and the program to run on the mobile device.
Creating the Worklight Adapter
The Worklight adapter provides the link between the mobile application and the CICS TG. In it I configured the hostname and port where the CICS TG is, the port number matches the value configured in
I then created two procedures, one for each of the web services that will be called by the application. The general outline of these procedures is to create the request JSON object, call the web service and return the result of the call. To get all the customers the procedure looks like:
Creating the Worklight Application
To call the procedures in the Worklight Adapter I use the client API provided by Worklight as in the following code snippet
To interact with the mobile device I make use of the Cordova plug-ins to access the camera and other applications on the device. In order to get a picture from the camera the following code snippet was used to open the camera, and then add the resulting picture to the page.
Through the creation of some new configuration pieces in the CICS TG and making use of the easy application design functionality provided by IBM Worklight I produced a professional looking application quickly and easily which leverages information stored in a back-end CICS TS system without any changes to the CICS server.