Attention: This feature is in Early Adopter Product (EAP) release status. We intend to provide the finalized feature in a future release. Please contact
Micro Focus SupportLine if you require further clarification.
The CICS Web Services feature is EAP for development and testing usage. It should not be used for production deployment in this product release.
In this tutorial, you use the bottom-up method to expose an existing CICS COBOL application, LOANPAYM, as a Web service. The LOANPAYM application accepts a principal amount, a loan term, and a rate as input values; then returns the calculated monthly loan payment.
Prerequisites
To complete this tutorial,
you must first install the IBM CCSID Conversion Tables and configure accordingly. See
CCSID Conversion Tables for more information.
To complete the
Test the loanPaym Web service provider
section of this tutorial, we recommend that you install a JSON requester tool.
Create the LoanJSON project
Use the CWSProject demonstration project to create a Visual Studio project for your CICS Web service.
- Using Windows Explorer or at a command prompt, create a project directory named
LoanJSON.
- Extract the
CICSWebServicesTemplate_VS.zip file, located in the
%PUBLIC%\Documents\Micro Focus\Enterprise Developer\Samples\Mainframe\CICS\Classic\CWS directory by default, to the new
LoanJSON project directory you created.
- From the
Enterprise Developer
for Visual Studio 2013 main menu, click
File > Open > Project/Solution.
- Browse to the new
LoanJSON project directory, and select the
CWSProject.cblproj project file; then click
Open. This starts the Solution Explorer.
Here, you rename the project to match the name of the service interface you are going to create. This is not mandatory in general, but done here to differentiate between tutorial projects.
- In the Solution Explorer, right-click the
CWSProject project; then select
Rename.
- Type
LoanJSON; then press
Enter.
Create a Service Interface
Map the input and output data areas of the LOANPAYM program.
- From the Solution Explorer in Visual Studio, right-click the
LoanJSON project; then click
Add >
New Item.
- In the left pane, expand
COBOL > Native; then click
Mainframe Subsystem.
- In the center pane, click
Service Interface.
- In the
Name field, type
LOANPAYM; then click
Add.
- On the Service Interface dialog box, select
Web Service from the
Type of interface drop-down list.
- Check
CWS-Type.
- Under
Transport Type, click
JSON.
The LOANPAYM program contains a Commarea interface; therefore, you can accept the default setting in the
Type of source field.
- Click
OK.
Enterprise Developer creates the service interface and loads it into the
Interface Mapper.
Define a Service Interface
- With the
Interface Mapper in focus, click
Operation >
New from the
Enterprise Developer main menu.
- In the
Operation Name field, type
LoanOperation.
- In the
Select program/copybook box, select
LOANPAYM.
- In the
Select input data area box, select
LOANPAYM(2).
- In the
Select output data area box, select
LOANPAYM(3).
- CICS Web Services always use default mappings; therefore, be sure that both
Create Default Mappings check boxes are checked (default).
- Click
OK to create the
LoanOperation operation.
- Click
File > Save LOANPAYM.svi to save the completed operation.
Generate and move the
LOANPAYM.wsbind file
- From the Solution Explorer, right-click
LOANPAYM.svi; then select
Generate WSBIND.
Because the
LOANPAYM.wsbind file is generated in the
LoanJSON project's root directory, but the output path is set to the project's
loadlib directory, you need to move the file from the
LoanJSON root directory to the project's
loadlib directory:
- Using Windows Explorer or at a command prompt, change to the
LoanJSON project directory.
- Copy or move
LOANPAYM.wsbind from the
LoanJSON directory to the
LoanJSON\loadlib directory.
Build the LoanJSON project
- From the Solution Explorer, right-click the
LoanJSON project; then select
Build.
Configure the enterprise server region
This tutorial uses the
CWSJSONenterprise server region created in
Tutorial: CICS Web Service Provider, JSON Request-Response Top-down Method to run the Web service provider.
Do one of the following:
- If you did not complete
Tutorial: CICS Web Service Provider, JSON Request-Response Top-down Method, skip the instructions in this section, go back to
Tutorial: CICS Web Service Provider, JSON Request-Response Top-down Method, and complete the sections titled
Create an enterprise server region and
Configure
CWSJSON resources. However, when selecting a project with which to associate the new region, check the
LoanJSON project instead of the
ReverseJSON project.
- If you created and configured
CWSJSON while completing
Tutorial: CICS Web Service Provider, JSON Request-Response Top-down Method, follow the steps in this section to update the
dfhdrdat file and properly associate
CWSJSON with the
LoanJSON project.
- Update the
dfhdrdat file
- When you create an
enterprise server region from the
Enterprise Developer Server Explorer, it stores some configuration information in the project's
system\dfhdrdat file. Therefore, to update the
LoanJSON project with this information, you can copy the file from the
ReverseJSON project to the
LoanJSON project:
- Using Windows Explorer or at a command prompt, copy the
dfhdrdat file located in the ReverseJSON project's
system directory to the
LoanJSON project's
system directory, overwriting the existing file.
- Associate the
LoanJSON project
- In previous tutorials, you have associated your project with an
enterprise server region as part of the steps to create the region. Because the region you are using here was previously associated with the ReverseJSON project, you need to change the association to the
LoanJSON project.
- On the Server Explorer, right-click
CWSJSON; then select
Associate with project.
Note: If a check mark shows next to
ReverseJSON, click
ReverseJSON to remove the association; then repeat this step and continue with step
2.
- Click
LoanJSON to create an association.
- If you are prompted to restart the server, answer
Yes; if you are not prompted, right-click
CWSJSON and select
Start from the context menu.
Verify Resources
After
CWSJSON is started, you can verify that the resources you have defined are installed and active.
- Start
Enterprise Server Administration
-
- From Server Explorer, right-click
Micro Focus Servers; then select
Administration.
Note: If this is the first time you have started the server you see a sign-on dialog box. If
Server is secured is checked, uncheck it; then click
OK. Unchecking
Server is secured prevents this dialog box from showing when you subsequently start the region. If
Server is secured is not checked, simply click
OK to clear the dialog box. If a Secure Storage prompt appears, click
No.
On the Home page, you should see the
CWSJSONenterprise server region listed.
- Start ES Monitor and Control (ESMAC)
-
- On the
Enterprise Server 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. This starts the ESMAC utility where you can view the defined resources.
- View defined resources
-
- On the ESMAC menu, select
Active from the drop-down list located under
Resources.
- Click the
WebSvc button. You should see the
LOANPAYM Web service listed and marked as
INSERVICE.
- Click the
Details button that corresponds to the
LOANPAYM Web service.
Notice the value for
WSBIND. This is determined by the information stored in your project.
- On the ESMAC menu, click
Pipeline; then click the
Details button that corresponds to
JSONPIPE. The Pipeline resource sets the response wait period, identifies the JSON configuration file, and the Web Service directory.
- On the ESMAC menu, click
URIMAP; then click the
Details button that corresponds to
PIPELINE and
/cics/services/LOANPAYM.
Enterprise Server generates URIMAPs to provide CICS with the information it needs to process requests. The name of each generated URIMAP begins with a pounds-sterling symbol (£).
To run your provider CICS Web service, you send a JSON request to an endpoint URL that routes the request to your
enterprise server region. The endpoint URL contains a URI value. The incoming request reads the installed URIMAPs to identify the map whose
Path value matches the
URI value of the endpoint URL. When the correct URIMAP is identified, CICS uses the data defined in the URIMAP, such as the name of the
Web Service and its associated
Pipeline, to process the request.
Test the
LOANPAYM Web service provider
Now that you have your Web service provider running with all of its resources active, you are ready to send a JSON request to run the Web service. You can do this using any json requester tool.
- Create a JSON POST request that contains the following:
{
"LOANPAYM" :
{
"LOANINP" :
{
"principal" : "50000",
"loanterm" : "180",
"rate" : "5.56"
}
}
}
- Submit the JSON request to the following endpoint URL:
http://localhost:5639/cics/services/LOANPAYM
You should receive the following JSON response:
{"LOANPAYMResponse": {"LOANOUT": {"monthlyPayment": "$410.13"}}}