Working...
Source File Validation Using Stage File and Throw New Fault in OIC
Use Case
In Oracle Integration Cloud (OIC), validating the source file before processing ensures data accuracy and integrity. This implementation:
- Reads the file using the Stage File action.
- Validates the data within the Stage Mapper using the defined schema.
- If validation errors exist, it throws a fault using the Throw New Fault activity.
Solution Steps
Step 1: Configure the Stage File Action
- Add a Stage File action to the integration.
- Select Read File and choose an appropriate read mode (e.g., "Read Entire File" or "Read in Chunks").
- Define the schema to structure the file content.
Step 2: Implement Validation in Stage Mapper
- Open the Stage Mapper and apply validation rules on fields (e.g., mandatory checks, format validation, length constraints).
- Create a Message Count Variable to track the number of validation errors.
- If a validation error is found, increment the message count and populate the
Message
field in the validation schema.
Example Validation Schema:
{
"Validation": [
{
"Message": "Error description"
}
]
}
Step 3: Throw a Custom Fault if Errors Exist
- Add an If condition after the Stage Mapper:
- Condition: Message Count > 0
- If the condition is met:
- Use Throw New Fault activity.
- Pass the validation messages in the fault payload.
Example Fault Response:
{
"Validation": [
{
"Message": "Missing required field: Employee ID"
},
{
"Message": "Invalid date format: Start Date"
}
]
}
Detailed screenshots:
Integration flow snap:
Read source file using nxsd:
Read raw file - one line as a column:
Write file using stage and validation json sample
Mapping:
Throw new fault:
Few of the validations conditions:
TBD
1. 1st record should start from 5310:
substring($ReadRawFile/nsmpr0:ReadResponse/ns22:FileRowSet/ns22:FileRow[position() = 1.0]/ns22:FileData, 1, 4 ) != "5310"
No comments:
Post a Comment