Scenario
- Service1: Returns user information
- Service2: Returns department information
- Matching: When
Service1.xDEPARTMANI == Service2.ChildDepartmentID, adds data from Service2 to Service1
Service1 Sample Output
Service2 Sample Output
Groovy Script
Explanation
This script performs the following operations:- Retrieving Data from Service1: Retrieves user information from the first service with GET request.
- Retrieving Data from Service2: Retrieves department information from the second service with POST request.
- Matching: Uses
linearFindfunction to find matching department information in Service2 for each record in Service1. - Data Combining: When a match is found, adds
ParentDepartmentIDandParentDepartmentNamefields from Service2 to Service1 record. - Returning Result: Returns combined data in JSON format.
This script should be run on the response line (Response Policy) because it uses the
responseBodyTextToClient variable.
