Sabtu, 18 November 2017

Scheduled Integration in Oracle Integration Cloud Service

In this article, we will take a look at the ability of Oracle Integration Cloud Service to Schedule an orchestrated integration. This is the very cool feature of Oracle ICS that develop a schedule integration with minimal efforts.

Let's take a look at how to achieve Scheduled integration.

From the Integration Screen page, Click on the Create button and select the Orchestration pattern

The first thing, we will see when creating an integration is the Create New Integration Dialog box


As we can see the dialog has a new toggle option which defaults to represent the common approach to Orchestration, that being event triggered by an event or object defined by a connection.

Let's configure the options shown in the Create New Integration Dialog box
  • What triggers this integration: Select Schedule. This is the option that creates the Scheduled integration itself
  • What do you want to call your integration: Enter any name of choice.
  • What does this integration do: Enter description of the integration
  • Identifier: Identifier would be picked automatically as soon as, Integration name will be entered. However, we can edit this
  • Version: Version of the integration
  • Which package does this integration belong to: Enter any package name of your choice. This is optional and can be left blank

With these values set we can complete the step using Create button. We will notice, the first triggering point is schedule with the calendar icon


Let's add any target to complete the integration. Here to complete this integration, we will use FTP adapter and will use writer operation. Complete the FTP adapter configuration wizard. 

Follow the blog which explains how to write files using FTP adapter.

Once the integration is ready, save and close the integration.


We will notice the first icon is the calendar icon which represents the integration is scheduled integration. Let's activate the integration with the help of toggle button which is in front of the integration.

Check the Enable tracing and Include payload button and click on Activate and Schedule button


Upon clicking the Activate and Schedule scheduled button, a new page will get open which will help us to setup the schedules.


Let the Type option Basic. In the Frequency section, click the icon to display a dropdown list for selecting the frequency with which to run the integration. As we define one frequency, we can specify additional values by clicking the icon to the right of the Frequency section.
  • Only Once: This is the default selection. This selection clears all settings except for the From field.
  • Hours and Minutes: Specify the hours and minutes at which to run the integration.
  • Days: Specify the days on which to run the integration
  • Weeks: Specify the weeks during which to run the integration
  • Months: Specify the months during which to run the integration



Click Save to validate the frequency settings. If there are any errors, a validation message is displayed in the upper left corner that describes how to resolve the errors.

The Advance option allows us to put the iCal expression. Let' try to configure this option. Click on the Advanced radio button.

Enter an iCal expression, and click Validate Expression. For example:

The following expression indicates that this integration runs each month on the 1st, 5th, and 10th days of the month at 5:30 AM, 10:30 AM, 3:30 PM

FREQ=MONTHLY;BYHOUR=1,5,10;BYMINUTE=5,10,15;BYSECOND=30;


We can also define multiple schedule frequencies. The following schedule runs every day 8:00 AM and 8:00 PM. 

Note: This configuration requires two schedules separated by the & sign:

FREQ=DAILY;BYHOUR=08;BYMINUTE=00;BYSECOND=0;
FREQ=DAILY;BYHOUR=20;BYMINUTE=00;BYSECOND=0;


  • In the This schedule is effective section, click the link to the right of From.
    • A menu is displayed for defining the start date of the schedule.


  • If you want to start the integration run when the schedule is activated:
    • Click When schedule starts.
  • If you want to explicitly set an integration run start date:
    • Select Modify start date.
    • Click the Calendar icon to select the month, year, and day and the hour, minute, and second at which to start the integration run.
    • Click OK.
  • In the Until section, click the link to the right.
    • A menu is displayed for defining the expiration date.
  • If you want the schedule run to never expire:
    • Select Never (repeat indefinitely)
  • If you want the integration run to have a fixed expiration date:
    • Select Choose expiry date.
    • Click the Calendar icon to select the month, year, and day and the hour, minute, and second at which to end the integration run.
    • Click OK.
Click Save. If successful, a message is displayed in the upper left corner.

Close the integration and click on the Start Schedule button

Once we click Start Schedule button, the page will show the Future run of the integration

Click Close button, it will take us to the integration page. Now the integration has been scheduled to run every day at 8:00 AM and 8:00 PM.

If we want to run the integration manually, just click on the Action menu in front of the Integration name and click Submit Now button


This will submit the integration and will complete all the action defined in the integration.
 

Sabtu, 11 November 2017

Logs in Oracle Integration Cloud Services(ICS)

The Integration Cloud Service dashboard provides a view into the activity stream for running integrations, such as details about successful responses received from the target application, successful responses sent to the source application, and target application invocations.

To monitor activity streams and download log files:
  • On the Integration Cloud Service toolbar, click Monitoring
  • Click Dashboards
  • The dashboard appears and shows processing information for all  running integrations
  • Click on  Download Diagnostics Logs to download the ics-logs.zip file for offline analysis
  • Unzip the file and see the below structure



Senin, 06 November 2017

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed

Sometimes users deal with "sun.security.validator.ValidatorException: PKIX path building failed" with the exception and don't know how to solve the issue.

Problem: This error occurred usually when we try to consume secured services using java client. Below is the stack trace that we usually get

 sun.security.validator.ValidatorException:
 PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException:
 unable to find valid certification path to requested target

 javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path   building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid   certification path to requested target
                sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
                sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1937)
                sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
                sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
                sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1478)
                sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:212)
                sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)
                sun.security.ssl.Handshaker.process_record(Handshaker.java:914)
                sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1050)
                sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1363)
                sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1391)



Cause:

Main reason for the issue is that SSL certificate has not been installed properly

Solution:

1) Download the InstallCert.java file from here

2) Compile the file using the command as below:
     
              javac InstallCert.java

3) Add Trusted Keystore

Run InstallCert.java using java InstallCert.java, with the hostname and https port, and press “1” when asking for input. It will add the “localhost” as a trusted keystore, and generate a file named “jssecacerts

C:\Ankur>java InstallCert localhost:443
Loading KeyStore C:\Program Files (x86)\Java\jre1.8.0_91\lib\security\cacerts...
Opening connection to localhost:443...
Starting SSL handshake...

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.ssl.Alerts.getSSLException(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
        at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
        at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
        at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)
        at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
        at sun.security.ssl.Handshaker.processLoop(Unknown Source)
        at sun.security.ssl.Handshaker.process_record(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
        at InstallCert.main(InstallCert.java:59)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.validator.PKIXValidator.doBuild(Unknown Source)
        at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
        at sun.security.validator.Validator.validate(Unknown Source)
        at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source)
        at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)
        at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
        at InstallCert$SavingTrustManager.checkServerTrusted(InstallCert.java:161)
        at sun.security.ssl.AbstractTrustManagerWrapper.checkServerTrusted(Unknown Source)
        ... 9 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.provider.certpath.SunCertPathBuilder.build(Unknown Source)
        at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
        at java.security.cert.CertPathBuilder.build(Unknown Source)
        ... 17 more

Server sent 1 certificate(s):

 1 Subject CN=Ankur-Jain
   Issuer  CN=Ankur-Jain
   sha1    d3 b9 1c 0d 37 15 43 eb 42 08 6e 28 f9 b9 14 51 b4 5d 80 fb
   md5     d0 0e b8 cf 3e af ee a7 75 96 7b 65 d0 a8 83 1f

Enter certificate to add to trusted keystore or 'q' to quit: [1]
1

[
[
  Version: V3
  Subject: CN=Ankur-Jain
  Signature Algorithm: SHA256withRSA, OID = 1.2.840.113549.1.1.11

  Key:  Sun RSA public key, 2048 bits
  modulus: 29097399406335862648603478718093032258106380849402774151925502342615178908568117666690377193826203615479790565960821376205940928458371313760609133959349461286885160113266037440511976960329613437120185785368606059740742844262213088886805653789914216591685771502790972206462685411556415317772895044855789311041156987953579907954163194290953047131042696647502021116508936286048203642300999439036533705336558235724297279695584190506372666605140794146250538573493778513998757194609517715519451722657765734837367627217395785262158854804147187586905921058319581450357763769002145000821758050508892633704219266564731848702777
  public exponent: 65537
  Validity: [From: Mon Jun 12 17:27:51 IST 2017,
               To: Thu Jun 10 17:27:51 IST 2027]
  Issuer: CN=Ankur-Jain
  SerialNumber: [    ef54124a a7408795]

Certificate Extensions: 3
[1]: ObjectId: 2.5.29.37 Criticality=false
ExtendedKeyUsages [
  serverAuth
]

[2]: ObjectId: 2.5.29.15 Criticality=false
KeyUsage [
  Key_Encipherment
  Data_Encipherment
]

[3]: ObjectId: 2.5.29.17 Criticality=false
SubjectAlternativeName [
  DNSName: Ankur-Jain
]

]
  Algorithm: [SHA256withRSA]
  Signature:
0000: A2 AD A1 B5 3C 3A 9D A4   DD 35 CC 7B 79 91 D2 FC  ....<:...5..y...
0010: 91 53 8A 43 4B 55 4C DF   D6 CB 5C 82 8F 1E 44 C5  .S.CKUL...\...D.
0020: D6 64 40 1B 7D FD 75 E7   D6 22 98 24 52 56 83 7C  .d@...u..".$RV..
0030: B8 89 F5 A6 DD 5F 5F A8   19 51 59 9D 6A DD 0E 69  .....__..QY.j..i
0040: 59 68 AD E8 2B EB 73 D3   F8 16 15 2F 1D FF 84 77  Yh..+.s..../...w
0050: 62 2F 05 24 78 EE 5E F9   13 81 AF 79 45 B0 D7 34  b/.$x.^....yE..4
0060: 19 54 52 15 39 0C 4B D5   6C E2 9E 78 38 7A 4C 7E  .TR.9.K.l..x8zL.
0070: 57 16 E3 AB F9 DC 56 07   13 D5 6B 2C E1 6D E5 1C  W.....V...k,.m..
0080: 3C DC 05 94 18 BE 99 7D   0B C6 51 C6 E2 8F DD 7A  <.........Q....z
0090: 32 6A C3 5B 49 12 F5 AD   8B 15 C7 D0 B7 F7 DC 7F  2j.[I...........
00A0: C0 9C 6E 9F 35 0D 33 92   53 84 C1 79 2F A8 F5 C5  ..n.5.3.S..y/...
00B0: F9 F5 F1 4F 7A F7 22 54   43 88 DF 83 D5 6B CD E7  ...Oz."TC....k..
00C0: 4C D2 49 66 D0 F5 57 40   0E DD 87 B4 8E CB 6B BD  L.If..W@......k.
00D0: C4 1F 99 E8 5B 92 5B 10   FB C6 DD EA 70 F7 B2 ED  ....[.[.....p...
00E0: 5E CF 02 44 5B 40 28 0B   97 72 01 EA 59 F1 F7 38  ^..D[@(..r..Y..8
00F0: 71 1C BD 48 32 93 7E 91   1F 8B 29 85 E2 A3 8B 8E  q..H2.....).....

]
Added certificate to keystore 'jssecacerts' using alias 'localhost-1' 


3) Verify Trusted Keystore

Check if the certificate has been added successfully or not using the same command again

C:\Ankur>java InstallCert localhost:443
Loading KeyStore jssecacerts...
Opening connection to localhost:443...
Starting SSL handshake...

No errors, certificate is already trusted

Server sent 1 certificate(s):

 1 Subject CN=Ankur-Jain
   Issuer  CN=Ankur-Jain
   sha1    d3 b9 1c 0d 37 15 43 eb 42 08 6e 28 f9 b9 14 51 b4 5d 80 fb
   md5     d0 0e b8 cf 3e af ee a7 75 96 7b 65 d0 a8 83 1f

Enter certificate to add to trusted keystore or 'q' to quit: [1]
q
KeyStore not changed


4) Copy jssecacerts: Copy the generated jssecacerts file at $JAVA_HOME/jre/lib/security folder

5) Invoke the service client and the problem went away.


Minggu, 05 November 2017

Bind query parameter in database adapter in Oracle Integration Cloud Service

In this blog, we will show you how to use bind parameter in SQL query when use Oracle Database adapter.

Bind parameters are required to get the result based on the certain parameters.

Use Case: Develop REST service that takes EmployeeId as a input parameter and return the response as below:

{  
   
"employeeId":"ABC@123",
   
"firstName":"Ankur",
   
"lastName":"Jain",
   
"Qualification":"MCA",
   
"Designation":"Sr. Manager"
}

This Use case requires only simple 4 steps to complete:

  • Create REST connection
  • Create DB connection
  • Create an Integration
  • Activate the Integration

Let's go step by step
  1. Create REST connection: The REST connection we are gonna to create will work as a Trigger point. We have already showcased the same how to create REST connection in one of my blog. Please check it out before moving forward.
  2. Create DB connection: DB connection will work as a Target point. We have already showcased how to create Oracle DB connection in one of my blog. Please check it out before moving forward.
  3. Create an Integration: Follow below steps to create an Integration
  • 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 you can edit it
        • Let the Version as it is
        • Enter the description in What does this integration do box
        • Leave the package box as it is
      • Integration pane will look like

      • Drag the TEST_REST_Conn Connection on the canvas from REST connection
      • Enter below information and Click Next
        • Name of the end point
        • Relative URI(must start with /) for example (/getemployee)
        • Select HTTP verb : GET
        • Select Add and review parameter for this endpoint radio button
        • Select Configure this endpoint to receive the response radio button
      • Select + Sign from Specify Query Parameters section to add request parameter. Enter EmployeeId in Name column and select string in Data Type column then click Next button
      • Select JSON sample radio button, click inline link and enter below payload. Click OK button then Next
      {  
         "employeeId":"ABC@123",
         
      "firstName":"Ankur",
         
      "lastName":"Jain",
         
      "Qualification":"MCA",
         
      "Designation":"Sr. Manager"
      }


      • Select Done button
      • Click Invokes from right navigation, Select Oracle Databases, drag and drop the TEST_DB_Conn below Map to GetEmployee
      • Enter below information and Click Next
        • Enter endpoint name(SelectEmployees) in What do you want to call your endpoint
        • Select Run a SQL Statement from What operation do you want to perform drop down
      • Enter below insert query in SQL query box and Click Validate SQL query to validate the entered query and Click Next button
      select employee_id, first_name,last_name,qualificatoin,designation from apps.employee_info where employee_id = #employeeId

      Note: Use # sign to define the binding parameters
      • Click Done button on the last screen
      • Edit the SelectEmployees mapper and Map EmployeeId parameter to employeeId
      • From Actions, drop Map activity just below the SelectEmployees 
      • Expand SelectEmployees-> SelectEmployeesOutputCollection -> SelectEmployeeOutput and map the fields as shown in the below screen shot

      Integration is completed. Let activate the integration and test using POSTMAN tool

      End point would be reachable on below URL:

      https://<ICS_URL>/integration/flowapi/rest/REST_SERVICE/v01/metadata/getemployee?EmployeeId=123

      Add Basic Authentication in the POST and hit the request




      Convert UTC Date & time to another timezone in Oracle Integration Cloud Service(ICS)

      Oracle Integration Cloud provides date and time in UTC (Coordinated Universal Time) format. So some time is required to change the UTC to another timezone as per the requirement.

      Oracle  ICS comes with out of the box XSLT function adjust-dateTime-to-timezone that alows to convert one timezone to another timezone.

      Whenever we tried to get the current time in Oracle ICS, it gives the time in the universal format.

      In this blog, we'll show how to convert UTC to IST timezone using the XSLT functions.

      We'll assume that we already have one Scheduled Integration in ICS and use the same integration to convert the UTC to IST(India Standard Time).

      Drop an assign activity on the integration canvas and provide name DateTime.

      Create one variable currentdate in the assign activity. Assign the below expression:

      string(fn:adjust-dateTime-to-timezone (xsd:dateTime(/nssrcmpr:schedule/nssrcmpr:startTime), 
      xsd:dayTimeDuration('PT5H30M')))



      In the expression, PT5H30M tell us the expected conversion timezone. It increases the UTC time to 5 hours 30 minutes(5H30M) ahead. We have taken 5H30M because IST timezone is +5:30 ahead to the UTC time.

      Same ways if we want to change in another timezone we can use the same expression to get the expected time zone.






      Minggu, 29 Oktober 2017

      Microsoft Contact Adapter in Oracle Integration Cloud Service (ICS)

      Oracle ICS provided Microsoft Contact adapter that allows us to create an integration with a Microsoft Contact application.

      Microsoft Contact Adapter in an Oracle Integration Cloud Service enables us to transfer files to a target Microsoft Contact server in an Oracle Integration Cloud Service integration.

      The Microsoft Contact Adapter is one of many predefined adapters included with Oracle Integration Cloud Service. We can configure the Microsoft Contact Adapter as a connection in an integration in Oracle Integration Cloud Service.

      Important Adapters






        Salesforce Adapter



        Pre-requisite for creating a connection
      • Click on Add an app button
      • Enter the Application Name and click Create button
      • Note the Application Id and save it somewhere
      • Click Generate New Password to generate a secret key
      • Note the Password that got generated and save it somewhere. You will not be able to see the password again after clicking on the Ok button
      • Click on the Add Platform button
      • Choose Web
      • Enter https://ICSURL:ICSPORT/icsapis/agent/oauth/callback in the Enter a URL field. For example https://icstest-324567.integration.us2.oraclecloud.com//icsapis/agent/oauth/callback
      • Scroll to the bottom of the page and click Save
      Now we have completed the pre-requisite and got the application id and secret key that is required to create a connection.

      Create Microsoft Contact Adapter Connection
      • Login into the ICS
      • Click on the Connections tile
      • Click on Create button from upper right
      • Search Microsoft Contact and Select adapter

      • Enter Name and click Create button

      • Click on Configure Security button
      • Enter below information and click on Provide Consent button
        • Security Policy: Select Microsoft Contact OAuth Authorization Code Credentials 
        • Client Id: This would be the Application id that got created during application creation
        • Client Secret: This would be the password that got created after clicking the Generate New Password in above section
        • Scope: https://outlook.office.com/Contacts.ReadWrite offline_access
      The scope might be different as per the need but offline_access is required after space


      Provide Consent button will allow ICS to interact with the MS account which was used to create application in https://apps.dev.microsoft.com/ if everything is correct
      • After clicking the Provide Consent it will ask the ICS credentials. Enter the credentials and click Ok button. These would be the same credentials that we use to login into the ICS

      • After that provide the MS account credentials. We will get the below page that will ask the permission to interact with the account. Click Yes
      • Once it is done, will get the Access Allowed! page
      • Go back to the Connection page and click on Test button
      • The connection will reach to the 100%. Click Save and close button