zOS ConnectEE DB2 Lab-06682k

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

In this lab you will go through the process of creating an API to access DB2 on z/OS.

The different steps


of the lab are:

1. Understand your work environment:

2. Create your DB2 services:

3. Create API.

4. Test API

REST Client

You will need a REST Client on your PC to do this lab.

The one shown in this lab is called Postman

Telnet or Putty or regrettably TSO OMVS

Some of the steps of this lab require the entering of commands in the Unix System Services ( USS ) part
of z/OS.

The best way to do this is to logon to the USS part of z/OS. To do that you need to use something like
telnet or putty.

To use telnet on Windows start a DOS Command window and then type in telnet at the prompt and you
should see this:
If you get a message saying command telnet not found then follow these steps to see if you can enable
telnet on your Windows PC:

Another option is to use a free utility called putty.


Step 2. Create DB2 REST Service

To create a REST service in DB2, you need to use a REST client such as Postman.

1. Encode your User ID and password

When you use Postman to create your REST service in Db2 you will need to send your RACF User ID and
Password in base64 encoded format.

To work out the base64 encoding in a browser go to this URL:

https://www.base64encode.org/

Enter the string to encode in the format Userid:password Note the character between the User ID and
Password is a colon, the one with two vertical dots like this :, not a semi-colan.

And then press the Encode button and display will return the above string in base64 encoded format.

TUZUMTM2OjFRQVoxUUFa
2. Test access to DB2 REST services

Start Postman, set the method to GET and enter the URL http://192.86.33.143:5040/services You will
also need to add two HTTP Headers

1 Content-Type with value application/json

2 Authorization with value Basic TUZUUjI1OklCTQ==

Where the string after word Basic is the base64 encoding of your RACF User ID and password from
previous step.

Postman display should look similar to that shown below:

Press the Send button and should get this result:


Save this REST API by clicking the down arrow to the right of Save and select ‘Save as’ like this

3. Create Db2 REST Service to query Employee Table

Next you will use Postman to create a REST service in DB2 to query the Employee Table.

Change the method to POST and set the URL to


http://192.86.33.143:5040/services/DB2ServiceManager

Click the Body tab and enter this JSON:

"requestType": "createService",

"sqlStmt": "SELECT * FROM DSN81210.EMP WHERE EMPNO = :EMPLOYEE_CODE",

"collectionID": "MyCollN", "serviceName": "getEmployee", "description": "Get employee by EMPNO"

Note to set the N in the collectionID value to your team number.

Click the Send button and should get this JSON response
STEP2 - CREATE a NEW DB2 SERVICE PROJECT

First open z/OS Connect EE perspective view>Host connections>Db2 Service


Manager(right click)>New DB2 Service Manager connection—Below screen comes and
then enter the Host name as IP address and Port no. given in the pdf (Name field
automatically populates). Then click on Save and Connect.
Then give the Mainframe credentials and the service is connected.
Then go to File>New>z/OS Connect EE Service Project> give necessary details using Postman
query as below and click Finish.
STEP3 - Import from DB2 Service Manager
STEP4 – Specify the connection reference
STEP5 - Deploy the service
STEP6 Create API

Create the API PROJECT and Import the service created above.
Deploy API Deploy the API to the zCEE server in the same way you did in the CICS Lab. Then right click on
the deployed API and select the ‘Open in Swagger UI’ option is same way you did in the CICS Lab and it
should look similar to this:

Scroll down to where the empNumber parameter is and enter a number such as 000020 as shown below
Test API from a browser Copy the URL from the Request URL area as shown below:

You might also like