With the new Convert Copybook Task, Forum Sentry allows the user to utilize a copybook layout to parse data from a variety of copybook formats and convert that data into XML or JSON responses. This can be extremely helpful when it comes to moving data from client side applications to mainframe applications or vice versa. The concept is take client side data constructed in various server side languages and utilize an existing copybook format to convert that data in order to have a backend application parse it.
Utilizing an Existing Copybook or Constructing a New Copybook
The Convert Copybook Task allows the user to import an existing copybook using the .cpy or .txt extension. When the copybook is completed in either format simply import the copybook into the task as shown in the screen shot below.
For this example we will use the following copybook containing 2 fields for parsing.
Creating the Convert Copybook Task
Let's start by creating a new task list for the Convery Copybook Task. Navigate to the Task List screen in Forum Sentry and create a new task list and name it SampleCopyBookTask -IN. Once you have created the new task list add a new task to Convert JSON. We will be using JSON for the incoming request and we will want to convert this request into data for our response that will be added later. Your Convert JSON task configuration should look like the screen shot below.
Once the Convert JSON task is added, let's go back to the task list and add the Convert Copybook task.
On the screen below you will see the option to import the copybook that was described earlier. Once you import the copybook, Forum Sentry will populate the record name (in this example the record name is "RCRD") into the Record field drop down menu. From this screen you have the option of converting the incoming request into XML, JSON, Data, or Creating an XML or JSON template.
For this example we will convert the incoming request into Data. Once the task is saved and completed go ahead and create a new Task List Group to assign it to for processing. In the example we are using the Task List Group created is named "SampleCopyBookTaskListGroup-IN".
In order to show the outgoing response in this example, let's create a new task list and name it "SampleCopyBookTask-OUT". This will give us a nice formatted response generated by Forum Sentry to analyze without the need for a backend server. For this task list add the Convert Copybook task as above with the exception of selecting the "Convert Data into XML" as we want the response to be in an XML format.
Assigning the Task Lists to JSON Policy
Next we need to build a policy to assign the new Task List Groups to. For this example build a new JSON Policy and create 2 virtual directories and name them "JSON to Copybook" and "Backend Copybook" as seen in the screenshot below.
Validating the Policy Setup
Now we are ready to validate that the task list is behaving as expected. Use any testing mechanism to submit a valid JSON request (SOAPSonar Project included in this article) into the uri for /request that was just created. As you can see in the Access logs all of the data from the JSON request is sent through the Convert Copybook task and then onto the /response uri.
And the /response uri has responded by parsing the incoming request through the copybook format provided and into an XML response.
We hope you have found this article helpful. In this example we have merely demonstrated only one of the functionalities of this task and we encourage you to test out all of the task functionality on your own to determine if this task will be beneficial to you and your company. As always, should you have any questions please do not hesitate to reach out to us.