Restriction: This topic applies to Windows environments only.
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
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
JSONPROV
enterprise server region.
The
Test the invkRevJ Web service requester section of this tutorial requires that you have access to a TN3270 emulator such as Rumba.
Note: CCSID conversion tables must also be installed before running this tutorial, but as these are also required to run the prerequisite
Tutorial: CICS Web Service Provider, JSON Request-Response Method, they should already be installed.
This tutorial assumes that your Eclipse project is set to
Build Automatically. If not, turn this feature on by clicking
Project > Build Automatically from the main menu.
Import the InvokeReverseJSON project
- In Eclipse, start the Team Developer Application Explorer.
- From the main menu, click
File > Import.
- Expand
General, and select
Existing Projects into Workspace; then click
Next.
- Select
Set root directory, then browse to the
%PUBLIC%\Documents\Micro Focus\Enterprise Developer\Samples\Mainframe\CICS\Classic\CWS\JSON\Requester\TopDown directory; then click
OK.
- On the
Projects list, ensure that
InvokeReverseJSON is checked.
- Under
Options, check
Copy projects into workspace; then click
Finish.
The Application Explorer now shows the
InvokeReverseJSON project, which is created in an
InvokeReverseJSON subdirectory of your current Eclipse workspace, and is built automatically.
Generate CICS Web Service requester components
Use the
New CICS Web Service wizard to generate the components of your Web service requester.
- From the Application Explorer, click the
InvokeReverseJSON project to select it.
- Click
File > New > CICS Web Service. This starts the
New CICS Web Service Wizard.
Note: If CICS Web Service is not listed, select
Other; then locate and select
CICS Web Service.
- Under
Service type, select
JSON message processing.
- From the drop-down list, select
CICS Web Service Requester (Top-Down, Linkable Interface); then click
Next.
The Project field is already populated with the name of the current project,
InvokeReverseJSON.
- In the
Service name field, type
invkRevJ; then click
Next.
- Click the
Browse button that corresponds to the
JSON schema field.
- Navigate to and select the
reverse.json file, located in your project's
schema folder.
- In the
Output artifacts group, type
REQ into the
Request file prefix field.
- Click the
Browse button that corresponds to the
Bundle field.
- Navigate to your project directory.
- Click
Make New Folder.
- Name the new folder
bundles; then press
Enter.
- Click the
bundles folder.
- Using the same method as before, create a new folder under
bundles named
REQBNDL.
- Select the
REQBNDL folder; then press
Enter.
- Click
OK.
- In the
JSON transform field, type
REVREQUEST; then click
Next.
- Click the
Browse button that corresponds to the
JSON schema field.
- Navigate to and select the
reverse.json file, located in your project's
schema folder.
- In the
Response file prefix field, type
RESP.
- Click the
Browse button that corresponds to the
Bundle field.
- Navigate to your project's
bundles directory.
- Using the same method as before, create a new directory under
bundles named
RESPBNDL.
- Select the
RESPBNDL folder; then press
Enter.
- Click
OK.
- In the
JSON transform field, type
REVRESPONSE; then click
Finish.
Enterprise Developer generates the following CICS Web Service components:
- REQ01.CPY
- A COBOL copybook that contains the request data structure.
- RESP01.CPY
- A COBOL copybook that contains the response data structure.
- bundles\REQBNDL\
-
- jsbinds\reverse.json
- The JSON schema that describes the request data structure.
- jsbinds\REVREQUEST.jsbind
- The JSON binding file that used to transform the COBOL request data into JSON.
- META-INF\cics.xml
- A manifest file that defines the type of bundle, it's location, and filename. In this case, the type is JSONTRANSFRM and its
name is REVREQUEST.
- REVREQUEST.log
- A log file that contains information about the content of the REVREQUEST.jsbind file. This log file can be useful to
Micro Focus
SupportLine to help diagnose problems should they arise.
- bundles\RESPBNDL\
-
- jsbinds\reverse.json
- The JSON schema that describes the response data structure.
- jsbinds\REVRESPONSE.jsbind
- The JSON binding file that used to transform the COBOL response message into COBOL.
- META-INF\cics.xml
- A manifest file that defines the type of bundle, it's location, and filename. In this case, the type is JSONTRANSFRM and its
name is REVRESPONSE.
- REVRESPONSE.log
- A log file that contains information about the content of the REVRESPONSE.jsbind file. This log file can be useful to
Micro Focus
SupportLine to help diagnose problems should they arise.
Analyze the
invkRevJ.cbl program
The
supplied
invkRevJ.cbl program
already contains the functionality that is required to invoke the
reverseJ 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.
- From the Application Explorer, double-click
invkRevJ.cbl to open it in the COBOL editor.
- Browse through the code, noting each block of code that corresponds to the JSON application linkable interface requirements.
Create an
enterprise server region
Here you use Server Explorer to create an
enterprise server region on which to run the requester Web service.
- On the Server Explorer, right-click
Local [localhost:86]; then select
New > Enterprise Server.
- In the
Name field, type
JSONREQ.
- Click the
Browse button that corresponds to the
Template field, and navigate to the
CICSWebServicesTemplate.xml file located in the
InvokeReverseJSON project folder.
- Double-click
CICSWebServicesTemplate.xml.
- On the list next to
Associate with projects, check
InvokeReverseJSON.
- Click
Finish.
The Server Explorer should now show the
JSONREQ
enterprise server region listed under
Local [localhost:86].
Configure JSONREQ resources
- Start
Enterprise Server Administration
-
- On the Server Explorer, right-click
JSONREQ; then select
Start.
- Start ES Monitor and Control (ESMAC)
-
- After JSONREQ has started, on the
Enterprise Server Administration Home page, click the
Details button located in the
Status column for the
JSONREQ region.
- On the
Server > Control page, click
ES Monitor & Control.
- Open the DEMOSTRT startup list
-
- On the ESMAC menu, click the drop-down list located under
Resources; then select
by Group.
- Click
Startup.
- Click the
Details button that corresponds to
DEMOSTRT.
- Add resource groups
- As with the JSONPROV
enterprise server region, the JSONREQ region requires the DFHWEB and DFHPIPE resource groups, and a resource group to contain the requester resources
Here, you add these resource groups to the startup list.
- On the CICS STARTUP - DEMOSTRT page, scroll down to the end of the list and type
DFHWEB into the empty field at the bottom; then click
Apply. ESMAC adds the DFHWEB group, and adds another empty field at the end of the list.
- In the new empty field, type
DFHPIPE; then click
Apply.
- In the new empty field, type
JSONREQ; then click
Apply.
- Create the JSONREQ 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
JSONREQ.
- In the
Description field, type
CICS Web Services JSON Requester Resources; then click
Add.
- Create and verify resources
- The
invkRevJ 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 JSONREQ page, click
URIMap.
- Complete these fields:
Name
|
REVRSURI
|
Description
|
URIMAP for JSON reverseJ request
|
Usage
|
Client
|
Port
|
5482
|
Host
|
localhost
|
Path
|
/cics/services/json/reverse
|
- Click
Add; then click
Apply.
- Click
Group List to return to the CICS Group JSONREQ page.
- Click
Bundle.
- Complete these fields:
Name
|
REQBNDL
|
Description
|
Input bundle to map the data structure to a JSON request
|
Bundle Dir
|
$IDE_BUNDLE_LOC\REQBNDL
|
- Click
Add; then click
Apply.
- Click
Group List to return to the CICS Group JSONREQ page.
- Click
Bundle.
- Complete these fields:
Name
|
RESPBNDL
|
Description
|
Output bundle to map the JSON response to a data structure
|
Bundle Dir
|
$IDE_BUNDLE_LOC\RESPBNDL
|
- Click
Add; then click
Apply.
- Click
Group List to return to the CICS Group JSONREQ page.
- Click
PCT.
- Complete these fields:
Name
|
INVJ
|
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
JSONREQ; 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 JSONREQ is started, use the ESMAC
Active feature to verify that the JSONREQ resources are installed and active.
Test the invkRevJ 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.
- If not already started, start the JSONPROV
enterprise server region from the Server Explorer.
- 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
JSONREQ; then select
Show TN3270 display.
- If using Rumba, press
F3 to bypass the CICS logon screen.
- Enter
INVJ.
The emulator should return your input string, reversed:
Hello
JSON