You can parse a message that you receive from the web service. When you parse the message, the REST Web Service Consume transformation receives data according to the structure that you specify for the response message in the method output definition.
For example, you might want to parse the following JSON response message:
{"name":"infa","message":"hello"}
To parse this response message, complete the following steps when you configure the transformation:
In the Developer tool mapping editor, scroll down in the mapping palette to locate the REST Web Service Consumer transformation and drag it to the mapping.
The
New REST Web Service Consumer Transformation
wizard appears.
Enter a name for the transformation.
Next to
HTTP Method
, select
Get
.
When you use the Get method, you do not configure an input mapping.
Click
Next
.
The wizard displays a message that input is not applicable when using the Get method.
Click
Next
.
Select
Create as empty
.
Next to
Show
, select
Output mapping
.
Design the method output definition based on the response message that you expect to receive.
The following image shows how the method output definition might appear:
Although the transformation receives a JSON response from the web service, the Data Integration Service automatically adds a root element named xmlRoot to the JSON response. When you configure the method output definition for a JSON response, configure the same root element xmlRoot.
Select
Output mapping
.
Configure the output mapping by dragging ports from the
Method output definition
area to the
Ports
area.
The following image shows an example of the output mapping:
Click
Finish
.
Select the transformation and navigate to the
Advanced
tab.
Configure the
Output Format
with
JSON
.
The following image shows how the transformation might appear when it is integrated in a mapping:
The following image shows the response that might appear when you run the mapping: