Friday, July 30, 2021

OIC - Resolved - Stage read file in segements - XML-22031 : Error variable not defined.

Scenario:

This is a strange error. I have a orchestrated integration which performs the following:
  • First list the files from s3 directory using sftp
  • Then for each file, it downloads the file and  reads the file reference using stage read in segments. 
  • In the read in segement, we are wrting the line records in the required erp comma separated format. 
  • The downloaded file size is ~21MB.

Observation:

During transformation, we received below error:

Xpath expression failed to execute.

The reason was javax.xml.transform.TransformerException. 

XML-22031 : (Error) Variable not defines for "currFileRef".

Screenshot from OIC: errored in the writeLineRecord stage activity.



Solution: 

This is an Oracle bug. During mapping if any fields are blanks, then this kind of issues can occure. 

Oracle recommended to use a scope in the read file in segemets. Whintin the scope, the writeline stage and mapper will be there.

Screenshot after change:



After this small change, I have tested again with same 21MB source payload and it has magically processed without any error.

Thursday, July 29, 2021

django - POST request and CSRF tokens

lets first know the difference between http get and post. 

HTTP GET :

  • The GET method is the default submission method for a form.
  • The GET method sends the data in the form of URL parameters. Therefore, any data sent with the help of the GET method remains visible in the URL. Since the data is exposed in the URL, the GET method is not considered to send sensitive information such as passwords.
  • The GET method reveals the data in the URL bar; therefore, the length of the URL increases. The maximum length of a URL is 2048 characters, so only a limited amount of data can be sent using the GET method. The following error occurs when we try to send more than 2048 characters using GET :

POST :

  • Data sent by the POST method never gets visible in the URL box, and therefore it is more secure than the GET method, and sensitive information can be sent with the help of this method.
  • Since the data is not visible in the URL query, the length of the URL remains less than 2048 characters, and a large amount of data can be sent with the help of the POST method.
  • Data is sent to the server in the form of packages in a separate communication with the processing script.


Now, we will start our discussion on CSRF tokens.

WHAT ARE CSRF TOKENS?

  • CSRF stands for Cross-Site Request Forgery.
  • The server-side application generates and transmits a huge, random, and unpredictable number to the client to make sure that the request is coming from the original client and not from a malicious website.
  • CSRF tokens are used to protect the site against CSRF attacks.


Use POST:

In the template, here index.html file add the post method in the form.

<form action="/removePunctuation" method="post">

In the views.py, replace all the request.GET.get with the request.POST.get. 

from django.http import HttpResponse
from django.shortcuts import render


def removePunc(request):
# text=request.GET.get('text','default')
text = request.POST.get('text', 'default')
# text = request.POST.get('text', 'default')
check = request.POST.get('removepunc','off')

If you now test from server, you will get the CSRF error:

Test:

Error:

Use CSRF token:

To overcome the CSRF error, add the {% csrf_token%} in the template form

<form action="/removePunctuation" method="post">{% csrf_token %}


Test:

Success page:

Wednesday, July 28, 2021

OIC - callback action

Callback action used to end a process and return to the trigger. 

For instance, if you add a switch activity and define a branch in which you add a callback. If some defined logic is not met, then it moves to this branch and the integration is stopped and the trigger receives a response indicating that the integration is stopped here. 

This action is only valid for delayed or asynchronous integrations.


Lets have a small POC and see:


TBD


OIC - SFTP operations - Move and delete

Generally OIC supports following  5 Ftp operations:

  • Read a file
  • Write a file
  • List Files
  • Delete a file
  • Download a file
Here, I will show you the steps for a POC for move and delete operation.

Steps:

Step1: create an app driven or any other integration and create a rest trigger connection and drag and drop in the integration and configure the following:

Provide a endpoint name
Verb as POST
URI: /
Configure the request payload option

Request payload as Json:

{
"sourceDirectory": "sourceDirectory",
"fileName":"sourceFileName",
"targetDirectory":"target",
"targetFileName":"targetFile",
"moveFileFlag":"Y",
"deleteFileFlag" : "Y"
}

Step2: Take a switch acrivity and mention the condition moveFileFlag="Y" and take a SFTP connection and config the following:

Provide endpoint name: moveFile
Operation: Move a file
Overwrite file option checked.
Next
Done

Map the following :

directory: your source direcrory
fileName: file name
targetDirectory
targetFilename:

Step3: now take again a switch and mention the condition as deleteFileFlag=Y and drop a ftp connection and configure the following:

Provide endpoint name:

Operation : delete a file

Next

Done

Map the following:

directory:

fileName:

Step4: add the tracking, save and activate amd test it with proper data.

Monday, July 26, 2021

OIC - invoke BI control report and store in s3 bucket using rest connection.

Requirement:

Once the inbound file like policy, sub ledger or FAH processed to Oracle ERP, we get a IMPORT REQUEST ID. Based on the import id, we have to fetch the control file details and save it as text file to s3 bucket.

High level Solution steps:

  • Create BI report invoke soap connection and aws S3 rest connection.
  • Invoke the BI report for the control file
  • Decode the response to base64 reference 
  • Take an amazone s3 rest connection and configure to store the  control response to s3.

Detailed Implementation steps:

Create BI report invoke soap connection:

Here we will configure  " ExternalReprtWSSService WSDL URL " which can be used to run a report. The same connection we will use in below steps while developing integration.

  1. Navigate to connection window and select SOAP adapter, give any meaningful name for connection.
  2. Enter the ExternalReportWSSService WSDL URL  and Select the TLS Version. TLS Version depends on your ERP Cloud Application Instance. Mostly it is TLSv1.1WSDL URL Format : https://<your oracle cloud application instance domain>/xmlpserver/services/ExternalReportWSSService?WSDL
  3. Choose Security policy as Username Password token and Enter the *Username and *Password of the Oracle Cloud Application Instance. Click SAVE and TEST the Connection.
Create AWS s3 rest invoke connection:

create a rest S3 connection using  following details:

Connection type: Rest api base url.
Connection URL: https://hostname
Security:  AWS Signature version 4 
Provide access key, secret key, 
AWS region:  like US West(Oregon) Region (us-west-2) 
Service Name: Amazon S3.

Invoke BI report :

Step1: Create a schedule orchestrated integration and specify a schedule parameter like importRequestID.

Step2: Next, drag and drop the BI report soap invoke connection and choose operation as runReport.

Step3: Next, open the mapper and map the following:

reportAbsolutePath: 
sizeOfDataChunkDownload: -1
ParameterNamesValues:
name : "P_IMPORT_REQUEST_ID"
values item: importRequestID.




Decode BI report response to base64 reference:

decodeBase64ToReference(reportBytes)

Invoke AWS s3 rest connection and configure:

Step1: Drag and drop your created AWS s3 rest connection and configure the following:

provide relative url as /{pathAndFileName}, 
verb put ,  
provide request payload as Binary and choose other media type and mention media type as "text/plain".

Step2: In the map, assign the following:

Template param: pathAndFilename : "/rootnode/inbound/poc/ctrl.txt"
Stream reference :  Base64 reference


Thursday, July 22, 2021

OIC - substring a string using index-within-string() function.

Suppose we have a variable which contains a string like "a/b/c/d.txt;name=value" and we need to take the value before the searchstring(;) then that we can achieve following 2 ways:

1. Using substring-before():

substring-before($string,";")

2. Using substring() and index-within-string() functions;

substring($string,1,oraext:index-within-string($string,";")

This function(index-within-string()) returns the zero based index of the first occurance od search string within the input string. The function returns -1 if search string is not found.


OIC - Opaque schema for creating base64Binary file

Opaque_schema.xsd: this will be used in the stage write file adapter configuration.

<?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>


Featured Post

11g to 12c OSB projects migration points

1. Export 11g OSB code and import in 12c Jdeveloper. Steps to import OSB project in Jdeveloper:   File⇾Import⇾Service Bus Resources⇾ Se...