Minggu, 10 Desember 2017

File Upload Process in Integration Cloud Services REST API

File upload is a very common aspect of each and every technology we used in our day to day projects as part of the REST service. This is very common requirement to upload a file that resides in the local computer and send it to the remote computer.

Sometimes we need to expose a REST service which should allow to upload files, process the data and store it some repository like a database, FTP etc..

In this blog, we are going to show how to use ICS REST adapter feature to upload a file and save the file as it is on some FTP location.

Below are the steps to achieve the use case:
  • Create REST Adapter as Trigger
  • Create FTP Adapter as Invoke
  • Create Orchestration Integration
  • TEST the Integration
Create REST Adapter as Trigger

There is one dedicated blog that explains, how to configure REST Adapter in Oracle ICS. Please have a look at the blog

Create FTP Adapter as Invoke

This has also been explained in another blog that shows, how to configure FTP Adapter in Oracle ICS. Please have a look at the blog

Create an Orchestration Integration

Create an Orchestrated Integration using steps:
  • Login into ICS console
  • Click on the Integration tile from ICS home page
  • Click on Create button from upper right corner
  • Select Orchestration pattern from the dialog box
  • Enter Below information and click on Create button
    • Select Application event or business object radio button
    • Enter Integration Name in What do you want to call your integration text box
    • An Identifier would be picked up automatically from Integration name, however, we can edit it
    • Let the Version as it is
    • Enter the description in What does this integration do input box
    • Leave the package input box as it is
  • Drag the TEST_REST_Conn Connection on the canvas from REST connection
  • Enter below information and Click Next
    • Name of the endpoint
    • Relative URI(must start with /)
    • Select HTTP verb as POST
    • Select Configure a request payload for this endpoint checkbox- This option allows us to assign payload in the next step
  • Select Accept attachments from request and Request in HTML form checkboxes then click Next and Done button
  • Drag & Drop the FTP connection on the canvas
  • Enter the Name in What do you want to call the endpoint input box and click Next button
  • Enter below information and click Next button
    • Select Operation: Select Write File
    • Select a Transfer Mode: Choose ASCII
    • Specify an Output directory: Enter the directory where you want to save the uploaded file
    • Specify a File Name Pattern: Enter the file name
  • Choose No under the Do you want to define a schema for this endpoint and click Next -> Done button
  • Edit the mapper and map the below
    • execute -> attachments -> attachment -> attachmentReference to ICSfile -> FileReference
    • partName -> fileName
partName element would contain the file name that will be uploaded


That configuration completes the integration.

Let's test the integration using POSTMAN tool:


Check the FTP location output directory that has been given during configuring FTP adapter.

Sabtu, 09 Desember 2017

Conditional Mapping in Oracle ICS

Conditional mapping is a very common question in each tech that we use in our projects. Someone asked me how to use conditional mapping in Oracle ICS which encouraged me to write this blog.

So, let's catch the below case:
  • Suppose there are two Query parameters, called A and B
  • There is another third output variable called C
  • Value of C should be as per below logic:
    • If A & B both are not null then output should be, C  = concat(A | B)
    • If A not null then output should be C  =  A
    • If B not null then output should be C  =  B
So, let's look how we can achieve the preceding use case with the power of XSLT.

We'll build our expression with the help of choose function available in Oracle ICS. Below attached screenshot depicts the logic that has been built based on the above logic


Since ICS mapper is very sophisticated, so such complex mapping is very difficult to build using ICS mapper. So I would suggest, export the integration and open the XSLT file and edit the code directly with the help of JDeveloper.

Below is the part of XSLT that has been built to achieve the use case:

<nsmpr0:C xml:id="id_17">
<xsl:choose xml:id="id_18">
<xsl:when test="/nstrgmpr:execute/nstrgmpr:QueryParameters/nsmpr1:A!='' and /nstrgmpr:execute/nstrgmpr:QueryParameters/nsmpr1:B!=''">
<xsl:value-of select="concat(/nstrgmpr:execute/nstrgmpr:QueryParameters/nsmpr1:A, ' | ', /nstrgmpr:execute/nstrgmpr:QueryParameters/nsmpr1:B)" />
</xsl:when>
<xsl:when test="/nstrgmpr:execute/nstrgmpr:QueryParameters/nsmpr1:A!=''">
<xsl:value-of select="/nstrgmpr:execute/nstrgmpr:QueryParameters/nsmpr1:A" />
</xsl:when>
<xsl:when test="/nstrgmpr:execute/nstrgmpr:QueryParameters/nsmpr1:B!=''">
<xsl:value-of select="/nstrgmpr:execute/nstrgmpr:QueryParameters/nsmpr1:B" />
</xsl:when>
</xsl:choose>
</nsmpr0:C>