Tuesday, September 7, 2021

OIC - Convert JSON to String

Use Case: Sometimes we come to situation where we get a source json file from source system and may need to send  the json as string to target system.

Source Json:

{

"firstname": "srinanda",

"lastname":"das"

}

Target Json as string:

{

"data": "{\n  \"firstname\" : \"srinanda\",\n  \"lastname\" : \"das\'\n}"

}

Opaque.xsd:

<?xml version='1.0' encoding='UTF-8'?>

<schema targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/opaque/" xmlns="http://www.w3.org/2001/XMLSchema">

<element name="opaqueElement" type="base64Binary"/>

</schema>


Implementation steps:,

Step1:  Rest trigger configure with request and response




Step2: Write a JSON file with the inputs using Stage file.




Sample.json contains:


Step3: Map the inputs to Write fields.


Step4: Read the files to opaque using Stage file.



Opaque.xsd


Map the read opaque reference to data response with decodebase64().


The flow is like below:


Test:



Wednesday, September 1, 2021

OIC - Fault Handling in OIC in details

UseCase Details: Here, we will capture the exception details from sub integration using scope default handler and sends them as response to the main integration and then from the main integration where if it finds the exception, it will throw new fault to scope handler and then it logs the exception and rethrow the fault to global scope where it will send mail notification to the customer.

Components:

Sub Integrations:

  • OIC_GetFiles_FTP : Take file name and file path as input and provide the file in base64 format and Exception details(ExceptionCode, ExceptionReason and ExceptionDetails) 
  • Generic_MailNotification: used send mails.

Main service:

  • SD_InboudErrorHandling.


Implementation steps:

Step1: OIC_GetFiles_FTP flow in bodyScope where it downloads the file from a FTP location based on file name and file path and then map the file as a response. 


Step2: In the bodysope default handler, added a map to add the bodyscope faulit details to response.



Step3: From main Integration, it calls the OIC_GetFiles and then checks if there is any exception. If exception exists, then it throws a new fault to bodyscope.


This is the exception condition used:


Switch and throw new fault block


Throw New Fault


Step4: Open the scope default handler


Step5: add the log the fault in a file or others and then rethrow the fault to Global fault.

Use Integrarion Metadata and Bodyscope fault details for enrichment

Step6: In the global fault, call the mail notification or call the incident creation service etc.

Logged fault in files:




Monday, August 30, 2021

OIC - How to create Rest ICS connection

Why to create a rest ICS/OIC connection:
This is very important when we are going to call any OIC artifacts or integrations or import or export integrations or update lookup or schedule integration etc. using rest protocol.

Connection Steps:

Step1: Go to connections and create a cknnection and REST type adapter.

Step2: provide following connection properties:
Connection type as REST API Base URL
TLS version: TLSv1.2
Connection URL: use your OIC URL(https://oic host name/)

Step3: Add security as Basic authentication and provide Username and password.

Step4: Save and Test.

OIC - Update lookup from a CSV file

UseCase: Here, we will feed a lookup name as input and then based on the lookup name we will fetch the Lookup csv file from a location using FTP protocol and then call lookup rest api to update the the respective lookup.


Rest API details to update lookup:

API : /ic/api/integration/v1/lookups/{name}

Verb : PUT

Request Json payload:

{"columns":["rightnow","soap"],"rows":[{"rowData":["RN1","SOAP1"]},{"rowData":["RN2","SOAP2"]}],"name":"myLookup"}


Prerequisites:

  • You should have a FTP connection to read the csv.
  • You should have a ICS rest connection.

Implementation steps:

Step1: We will feed lookup name.

URI: /update/{lookupName}



Step2: Read the file from a location using FTP and parse with a csv sample file schema.


In the map, concat lookup name with .csv
concat(lookupName,".csv")

Step3: Rest API URL configure to update Lookup.


Step4: Provide the sample Json request payload.


Step5: Map the lookup name and csv response to Lookup update rest request.

►Here haedcoded, "Country_Code" and "Country_Name" to each Columns.
►For each lookup row map to rows and map the code and name fields to each rowData.
►Map template lookup name to name.
►Map input template lookup name to rest request template parameter name.




The Integration flow looks below:


Before lookup update:


After update:




OIC - send Binary object as rest response

UseCase: Here, we will send .JPG object as input using rest trigger and fetch the file using FTP protocol and send as Rest binary response.

Note: we can also choose document, text or png type or other media types.


Implementations steps:

Step1: Take a rest trigger and configure. 

Verb: Get.

Add and review parameters for this endpoint checked

Configure this endpoint to trceive the response checked


Step2: Add Query paramter as Object Name


Step3: select the response payload format as Binary and choose media type as per requirement. Here, i take image/jpeg. 


Step4: Download the file using FTP and map the input object name.



Step5: Add the download response (file reference) to rest response stream reference.


The Integration looks as below:


Open the endpoint url with object name in the browser.


You can see the object in the browser.



Saturday, August 28, 2021

OIC - Search Data from CSV file

Usecase: Here, I will show you how you can search employee information from a CSV file using empid.

High level steps:

  • Add rest configure to fetch emp details based on id
  • Read csv file using FTP connection
  • Map the searching logic to show in rest response.

Implementation:

Step1: Add an App driven orchestratation integration style and add a rest connection and configure id template param and emp details as response.




Step2: Add FTP connection and read the file and use a sample csv file.



Step3: Map the fields as below:

Take XSLT view and add for each on top of Email and map for each source Emp.
Then add if block inside for each and add the condition csv file empid = template id
Map all the fields.


XSLT code view will be like that:

Now the integration flow looks like below


Step4: Add the tracking and save and activate and test


CSV file contents:





Featured Post

OIC - Source File Validation Using Stage File and Throw New Fault in OIC

Working... Source File Validation Using Stage File and Throw New Fault in OIC Use Case In Oracle Integration Cloud (OIC), validating the s...