In this tutorial, you use the top-down method to create a Web service requester that runs the provider Web service you created
in the previous tutorial.
Prerequisites
If you have not done so already, you must install the IBM-37, IBM-437, and 002501B5 CCSID tables before attempting this tutorial.
See
To install CCSID tables for instructions.
Before attempting to complete this tutorial, you must first complete
Tutorial: CICS Web Service Provider from JSON, Request-Response Top-down Method. This is required because the requester generated in this tutorial runs the provider Web service you created in the previous
tutorial and that runs on the
CWSJSON
enterprise server region.
The
Test the invkRevJCICSClientApp Web service requester section of this tutorial requires that you have access to a TN3270 emulator such as
Rumba+ Desktop.
Generate CICS Web Service requester components
Use the
Generate Web Service dialog box to generate the components of your Web service requester.
- From the Solution Explorer, expand the
ReverseJSON project's
json folder; then Ctrl-click both the
reverseReq.json and
reverseResp.json files.
- Right-click the selected
.json files; then select
Generate Web Service from the context menu.
- In the Generate Web Service dialog box, ensure that
reverseReq.json populates the
(for request) field, and
reverseResp.json populates the
(for response) field.
- In the
Generate group, select the
Client radio button.
- In the
Program group, check
CICS.
- In the
Program group's
Name field, type
invkRevJ, which is the name for the generated COBOL skeleton program.
- Click
OK.
Enterprise Developer generates a new project named
invkRevJCICSClientApp. It contains:
- invkRevJ.cbl
- A skeleton CICS program.
- InvkRevJInBundle
- A folder that contains generated input files.
- jsbinds/invkRevI.json
- A JSBIND file for converting between input JSON messages and COBOL data structures.
- jsbinds/reverseReq.json
- A copy of the input JSON that corresponds to the
invkRevJ.cbl program.
- META-INF/cics.xml
- A reference file used by Enterprise Server to establish the structure of the input bundle directory.
- InvkRevJOutBundle
- A folder that contains generated output files.
- jsbinds/invkRevO.json
- A JSBIND file for converting between output JSON messages and COBOL data structures.
- jsbinds/reverseResp.json
- A copy of the output JSON that corresponds to the
invkRevJ.cbl program.
- META-INF/cics.xml
- A reference file used by Enterprise Server to establish the structure of the output bundle directory.
Implement the service
The
generated
invkRevJ.cbl program
should provide the functionality that is required to invoke the
reverse service. Any JSON application that uses a linkable interface, including
invkRevJ.cbl, is required to do the following:
- Populate the request structure.
- PUT that data into a CONTAINER named DFHJSON-DATA.
- PUT the name of the JSONTRANSFRM resource used to transform the COBOL request data to JSON into a CONTAINER named DFHJSON-TRANSFRM.
- LINK to DFHJSON, which includes:
- Locating the appropriate JSBIND file by using the JSONTRANSFRM resource named in the DFHJSON-TRANSFRM CONTAINER.
- Transforming the content of the DFHJSON-DATA CONTAINER into JSON using the JSBIND file and placing it into the DFHJSON-JSON
CONTAINER.
- SEND the request and RECEIVE the response, which includes:
- Using WEB OPEN to open a connection to the server hosting the service.
- Using WEB CONVERSE to SEND the request to the server and RECEIVE the response. This is done by supplying the request message
via the DFHJSON CONTAINER and receiving the response message into the same CONTAINER.
- Using WEB CLOSE to close the connection to the server.
- PUT the name of the JSONTRANSFRM resource used to transform the JSON response message to COBOL into a CONTAINER named DFHJSON-TRANSFRM.
- LINK to DFHJSON, which repeats the same procedure as before.
- Populates the response structure by GETting the content of the DFHJSON-DATA CONTAINER.
To provide the program with an input and direct the output to your terminal, you must edit the code.
- From the
Solution Explorer, double-click
invkRevJ.cbl to open it in the COBOL editor.
- In the
PROCEDURE DIVISION,
WS-OP-1 section, add the following
MOVE statements before the
EXEC CICS PUT CONTAINER statement:
move 'esaelPeMesreveR' to myString
- After the
EXEC CICS GET CONTAINER command for
DFHJSON-DATA, add the following code to send the reversed string back to the terminal:
exec cics send text
from(reversedString)
freekb
end-exec
- Save the program and exit the editor.
Build the invkRevJCICSClientApp project
- From the Solution Explorer, right-click the
invkRevJCICSClientApp project; then select
Build.
Move the
invkRevJ.dll file
Because the
invkRevJ.dll file is generated to the
ReverseJSON project's
invkRevJCICSClientApp\bin\x86\Debug directory, but the output path is set to the
ReverseJSON project's
loadlib directory, you need to move the file from
invkRevJCICSClientApp\bin\x86\Debug directory to the project's
loadlib directory so that
Enterprise Server finds the correct file.
- Using Windows Explorer or at a command prompt, change to the
ReverseJSON project directory.
- Copy or move the
invkRevJ.dll file from the
invkRevJCICSClientApp\bin\x86\Debug directory to the
loadlib directory.
Configure CWSJSON resources
To run the invkRevJCICSClientApp Web service requester using the CWSJSON
enterprise server region you created in the previous tutorial, you must add the appropriate resources to the startup list and add and configure additional
resources required by the CICS program.
- Start the CWSJSON
enterprise server region
-
- Start
Enterprise Server Administration from Server Explorer.
- On Server Explorer, right-click
CWSJSON; then select
Start.
- Start ES Monitor and Control (ESMAC)
-
- After CWSJSON has started, on the Administration Home page, click the
Details button located in the
Status column for the
CWSJSON region.
- On the
Server > Control page, click
ES Monitor & Control.
- Add CWSJSONR to the startup list
-
- On the ESMAC menu ribbon, click the
Resources drop-down list; then select
by Group.
- Click
Startup.
- Click the
Details button that corresponds to the DEMOSTRT startup list.
- On the CICS STARTUP - DEMOSTRT page, scroll down to the end of the list and type
CWSJSONR into the empty field at the bottom; then click
Apply.
As with the previous tutorial, you need to create the CWSJSONR resource group.
- Create the CWSJSONR resource group
-
- On the ESMAC menu, click the
Groups button located under
Resources.
- On the CICS Resource Groups page, click
New.
- In the
Name field, type
CWSJSONR.
- In the
Description field, type
CICS Web Services JSON Requester Resources; then click
Add.
- Create and verify resources
- The invkRevJCICSClientApp program requires a URIMap resource, a pair of Bundle resources, and a PCT resource used to invoke
the Reverse Web service from a TN3270 terminal emulator.
- On the CICS Group CWSJSONR page, click
URIMap.
- Complete these fields:
Name
|
reverseR
|
Description
|
My CICS Requester URIMap
|
Usage
|
Client
|
Port
|
5639
|
Host
|
localhost
|
Path
|
/cics/services/reverse
|
- Click
Add; then click
Apply.
- Click
Group List to return to the CICS Group CWSJSONR page.
- Click
Bundle.
- Complete these fields:
Name
|
INVKRVJI
|
Description
|
Input bundle to map the data structure to a JSON request
|
Bundle Dir
|
$IDE_PROJECT_LOC\invkRevJCICSClientApp\invkRevJInBundle
|
- Click
Add; then click
Apply.
- Click
Group List to return to the CICS Group CWSJSONR page.
- Click
Bundle.
- Complete these fields:
Name
|
INVKRVJO
|
Description
|
Output bundle to map the JSON response to a data structure
|
Bundle Dir
|
$IDE_PROJECT_LOC\invkRevJCICSClientApp\invkRevJOutBundle
|
- Click
Add; then click
Apply.
- Click
Group List to return to the CICS Group CWSJSONR page.
- Click
PCT.
- Complete these fields:
Name
|
RVRS
|
Description
|
CWS transaction to invoke the reverse service
|
Program Name
|
invkRevJ
|
- Click
Add; then click
Apply.
- To return to the Administration Home page, click
Home at the top of the ESMAC menu.
You can install the new resources by stopping and starting the region.
- From the
Enterprise Developer Server Explorer, right-click
CWSJSON; then select
Restart. This stops and then starts the CWSJSON
enterprise server region, automatically installing and loading the newly added resources on the startup list.
- After CWSJSON is started, use the ESMAC
Active feature to verify that the CWSJSONR resources are installed and active.
Test the invkRevJCICSClientApp Web service requester
Now that you have your Web service requester running with all of its resources active, you are ready to run it from a TN3270
terminal emulator.
- Optionally, test to confirm that the ReverseJSON provider is running by repeating the
Test the ReverseJSON Web service provider section in the
Tutorial: CICS Web Service Provider, JSON Request-Response Top-down Method tutorial.
- From the
Enterprise Developer Server Explorer, right-click
CWSJSON; then select
Show TN3270 display.
- If using
Rumba+ Desktop, press
F3 to bypass the CICS logon screen.
- Enter
RVRS.
The emulator should return your input string, reversed:
Hello
JSON