Brief introduction
The WebSphere cast Iron (later referred to as Cast Iron) is widely used for integration and migration across internal and external applications. In the past, JSON was widely used as a transport type for the REST API because its format was lightweight compared to XML.
In Cast Iron, you can create and expose a JSON based API, an integration process that accepts requests and sends responses in JSON format. The Cast Iron uses XML and XML schemas. Cast Iron introduces two new activities for processing JSON data: Read JSON and Write JSON. These activities are useful in the process of creating a consolidation process that represents the JSON-based API in Cast Iron. This article describes how to create a consolidation process that is exposed as an API that can receive and emit JSON data.
Building a JSON-based API adds two digits to the Cast Iron
In this scenario, you will learn how to expose a REST API that receives a two-digit request by using the Read JSON and Write JSON activity, and sends the sum of the input numbers in the JSON message as a response. The sample request and response JSON message is shown in table 1.
You must build the consolidation process to complete the scenario described above. The consolidation process acts as a JSON-based REST API to add two numbers to the external world, as shown in Figure 1.
Figure 1. Add two digital-API integration process Design
The Receive Input Numbers (receive request) receives a JSON request containing two digits that need to be added. Table 2 shows the steps to complete the check list for the Receive Input Numbers activity.
Convert to XML activity (Read JSON) converts JSON-formatted data to XML:
Configure the Read JSON by completing the following steps. You must use a JSON message to configure the JSON activity. Select the use JSON or XML messages option from the Configure window as the message type, as shown in Figure 2.
Figure 2. Configure Convert to XML activity
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/script/