Mainframe CICS TG - API Exercise
Introduction
This exercise will develop your skills with OpenLegacy IDE by generating Java models from existing SDK and creating API controller to validate end to end process .
Pre-Requirements
OpenLegacy IDE 4.5.2 (Full installation including JDK and all Maven dependencies).
Mainframe CICS TG - SDK Exercise
Internet Connection
Exercise Definition
Create a new API Project.
Generate API from existing SDK project.
Test the API with swagger.
Step 1 – Create a New API Project
First, we will create a new API project using OpenLegacy IDE.
The purpose of the API project is to allow easy end to end access in to legacy backends, using standard and easy to use Java code.
Project Setup
Create a new OpenLegacy API project.
Open the New Project Wizard (you have three options):
File → New → OpenLegacy API Project
Alt+Shift+N → OpenLegacy API Project
File → New → Project → Select OpenLegacy API Project from the drop-down
Define the project name and the default package
Click at the Default Package field, to automatically fill it up.
Press Next and add the SDK project that was created in SDK exercise as the reference project.
Clean the project
Step 2 – Generate API from SDK
Right-Click on the API project → OpenLegacy → Generate API from SDK
Name the service
Select from the
Fininq2
model thecustId
as input and change its name tocustomerId
for better readabilitySelect from the
Fininq2
model thecreditCards
as outputClick OK
Uncheck Use Input wrapper AND default method
in the Method Tab, change the HTTP Method to
GET
. define the Method path as/{customerId}
to align with REST best practices and save the changes
Step 3 – Run and Test your API
Right-Click on the API project → OpenLegacy → Run Application
Open the browser on http://localhost:8080/swagger
Authorize through Oauth2
Client Id:
client_id
Client Secret:
client_secret
Click on the API we've created → Try it out
Set dummy customer ID as input (for example:
412-83254
)You should see successful respond returned directly from the mainframe CICS program
FININQ2
!
Summary
In this exercise we have presented an end to end integration with Mainframe CICS TG using Openlegacy IDE within just a couple of minutes.
We have started from a COBOL source of a program(SDK exercise) we wanted to expose and automatically generated Java SDK that enables calling the underlying program, then we have presented the creation of a REST API utilizing the Mainframe CICS TG SDK.
We used the IDE to better model and design the API and showed how it works with a standard Swaager page.