Create a Source transformation in the Mapping Designer to read data from the web service application.
When you select a REST V2 connection for a Source transformation in a mapping to read data from a web service application, specify Operations on the Source tab of the Source transformation. The Secure Agent displays operation IDs specified in the swagger specification.
Select an operation ID, configure the request message from the sample template provided in the request message editor, and configure the advanced properties for the operation. If you want to write to a relational target, define a relational structure for the source data by mapping the incoming fields that is in hierarchical format to the output fields in relational format. When you run the mapping, the Secure Agent retrieves data for the specified operation from the web service application.
Configuring a request using Request Message Editor
When you create a Source transformation, configure an XML request message for the operation that you want to perform in the web service application.
Use the Request Message Editor to create a request message. The request message is in XML format. You can use the sample request message for the operation and then customize the request message to specify the data that you want to enter into the data flow.
To customize your request, copy the request message from the sample template to the Request Message Editor pane where you can edit the XML message and add the attributes for the request. Remove unnecessary and empty tags from the request message to avoid operation failure.
If you have not defined the request body or parameters in the OpenAPI specification, the request message template displays a static field named Request_Port. Copy the request message from the sample template to the Request Message Editor pane where you can edit the XML message and add the attributes for the request.
Header fields, path parameters, and query parameters appear as fields in source, target, midstream transformations.
Parameterizing the input values in a request message
You can use in-out parameters to represent input values in a request XML.
Configure the in-out parameters in the Mapping Designer. From the Mapping Design page, you open the parameters panel and configure an in-out parameter.
The following image shows a configured empID in-out parameter value:
After you configure a parameter, use the parameter name in the following format, $$Name, in a request message. The XML uses the values of fields from the parameterized object.
For example, you want to use parameterized empID in an XML Request for a CouchDB_INPUT operation.
The following sample request shows the parameterized values that you can specify in an XML request:
<!--1 or more repetitions:--> <proc:CouchDB_INPUT xmlns:proc="http://xml.schemas/infa/procedure/"> <!--Optional:--> <CouchDB> <!--1 or more repetitions:--> <emp> $$empID </emp> </CouchDB> </proc:CouchDB_INPUT>
Configuring values for in-out parameters in a mapping
You can use an in-out parameter that holds a variable value that can change each time a task runs to manage incremental data loading.
Add the in-out parameterized field in complex expressions in a mapping if you want to update the parameters when each task runs. The in-out parameter acts like a placeholder for a value that stores a task stage. Data Integration evaluates the parameter at runtime based on the specified configuration.
For example, you can use the following parameterized values in an Expression transformation:
In the example, SetVariable function sets the parameter value each time the mapping task runs. You set a default value for the $$empID parameter. You want to update the value of $$empID by one every time the task runs.
The following image shows the logic used in expression transformation to assign value to in-out parameter in the Mapping Designer:
When the task runs, the Secure Agent updates the in-out parameters based on the specified logic in the expression.
Field mapping in a source transformation
The response message format follows the service response definition in the Swagger or OpenAPI specification file. You can map response fields from a hierarchical to a relational structure of output groups and fields.
After you configure an operation for a source and specify the request message, create the relational format from the hierarchical data to include groups and fields that you want in the output.
To do this, select the elements in the response structure that you want to include as output fields. The Secure Agent converts the XML response in the hierarchical structure to relational groups at run time.
If you have not defined the response body in the swagger or OpenAPI specification, the field mapping displays a static field named Response_Port.
The field mapping displays static fields named OtherResponseheaders and OtherCookies that contain response headers and cookies.
Creating packed fields
If you do not want to parse hierarchical elements, you can pack the elements into one field. You can also pack array elements when you write to the target.
A pack icon appears next to elements on the Field Mapping tab. When you select the pack icon that appears next to the element, the agent packs the element and its child elements into a single XML string during runtime. You cannot select fields that are child elements of packed fields in field mapping.
You can unpack fields by clicking on the pack icon.
To pack the fields, click on the pack icon that appears next to the rows element.
The following image shows the packed rows element:
The following sample shows the output of the Rows field in the target file after you run the task: