In this blog, let's create a basic inbound integration flow that receives an EDI document through a REST request, parses and validates the EDI, converts it to XML, and returns the XML in the response.
We shall use REST adapter to keep our blog simple but, you can replace it as per your business requirement, could be FTP adapter, SOAP or any other technology adapters/application specific adapter.
Prerequisites for implementing this use case: Prior implementation experience with Oracle Integration or Basic knowledge of using Oracle Integration and refer my previous blogs on B2B
Let us look at the with the implementation:
- In the navigation pane of Oracle Integration, click Integrations.
- On the Integrations page, click Create.
- Select App Driven Orchestration as the style to use. The Create New Integration dialog is displayed.
- In the What do you want to call your integration? field, enter Inbound EDI via REST, then click Create
Configure the REST Adapter Trigger Connection
On the integration canvas, click the start node and select Sample REST Endpoint Interface as the trigger connection.
The Adapter Endpoint Configuration Wizard opens.
- On the Basic Info page, enter the following details:
- In the What do you want to call your endpoint? field, enter Receive-EDI.
- Enter /inbound_edi as the endpoint's relative resource URI.
- Select POST as the action to perform on the endpoint.
- Select to configure both request and response for this endpoint and click on Next
2. On the Request page:
- Select Binary in the Select the request payload format field.
Most EDI documents contain only textual data, but they may also include line breaks and special characters, which are used as delimiters. A few EDI documents contain raw binary data, such as images, along with text. Therefore, select the request payload format as Binary.
- Select Other Media Type as the media type you want the endpoint to receive.
- In the Media Type field, enter application/EDI-X12.
3. In the Response page:
- Select JSON Sample in the Select the response payload format field.
- Click the inline link next to enter sample JSON.
- In the resulting page, enter the following sample JSON and click OK.
"validationErrors": "xxxx", "translated_payload": "xxxx"
- Notice that JSON is automatically selected as the response media type
- Click Next, and on the Summary page, click Done to complete the REST Adapter configuration.
- The integration flow is now represented as follows in the canvas and click on Save to save your integration flow.
Configure the EDI Translate Action
Add an EDI translate action to the flow to translate an EDI document into an Oracle Integration XML message.
- On the right side of the canvas, click Actions , drag EDI Translate, and drop it after the first Receive-EDI element.
The Configure EDI Translate Action wizard opens.
- On the Basic Info page, enter EDI-Translate as the name for the action, and click Next.
- On the Select Data Formats page, enter the following details:
- Leave the Inbound EDI message to Oracle Integration message radio button selected.
- Select the document version as 8010 (or 4010..)
- Select the document type as 850 (Purchase Order).
- Select the document definition as the one which you have created OR Standard.
- Select the EDI character encoding as UTF8.
- Select Yes in the Perform validations on input data? field. Click Next.
5. On the Summary page, click Done to complete the configuration, Change layout to Horizontal and click on Save to save your integration flow.
Note that the corresponding mapping element is automatically added to the integration flow
Configure Mapping Actions
Configure data mappings for the EDI-Translate action and Receive-EDI action in order to successfully parse the incoming EDI message and translate it to an XML message.
Configure the Map to EDI-Translate Action
- Click the Map to EDI-Translate action and select Edit.
- Map streamReference on the left to edi-payload on the right, within TranslateInput.
- Click Switch to Developer View and edit the expression for the mapping.
Prefix the function call encodeReferenceToBase64 to the existing edi-payload expression as follows: oraext:encodeReferenceToBase64 (/nssrcmpr:execute/ns20:streamReference ). Click Save
- Click Validate and then Close.
Configure the Map to Receive-EDI Action
- Click the Map to Receive-EDI action and select Edit.
- Click Switch to Developer View .
- Map edi-xml-document (present on the left within $EDI-Translate, under TranslateOutput) to translated_payload, within the response-wrapper on the right.
To achieve this mapping, drag and drop get-content-as-string function on to the translated_payload and now drag and drop edi-xml-document with in the () . Click Save.
- Map translation-status within the same TranslateOutput element to translate_result on the right.
- Map validation-errors-present to hasError.
- Map validation-error-report (TranslateOutput > validation-errors) to validationErrors.
- Click Validate and then Close.
Activate the Integration
Check for errors, save, and activate the integration flow.
- You'll notice an error notification on the canvas. To resolve it, click Actions Menu in the top-right corner of canvas, and select Tracking.
- In the resulting dialog, select streamReference on the left and move it to the table on the right.
- Click Save.
- Save the integration and click Close.
- On the Integrations page, click the toggle button against your integration to activate it.
- Click Activate in the Activate Integration dialog.
Parse Your First EDI Document
To execute your sample integration, send a request from a REST client tool, such as Postman OR you can use Oracle Integration console to test. If you use OI Console, you can ignore steps 1-3 given below.
Create a request definition on the REST client tool as follows:
- Define the request to send an HTTP POST to the URL: http://host:port/ic/api/integration/v1/flows/rest/INBOUND_EDI_VIA_REST/1.0/inbound_edi
- Configure authorization for the request. Select HTTP Basic Auth and provide the username and password to your Oracle Integration instance.
- Add an HTTP header with Content-Type as KEY and application/EDI-X12 as VALUE.
- Use the sample EDI X12 PO
- Send the request from the REST client.
- Verify the response from the integration flow.
Check if the response status is 200 OK and the JSON is displayed as follows:
The translate_result parameter with the value Success indicates that the EDI X12 document was parsed and translated successfully.
For more information, please visit Oracle docs
Refer my other blogs