Jumat, 07 Juli 2017

Integration on ICS to expose REST service

This blog is very useful for those who is keen to know, how to create REST services in ICS. This is very straight forward.

After this blog you have learned to how to develop REST service in ICS.

Use Case: Develop REST service that exposes the below json and inserts the same in Oracle DB table.

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

This Use case requires only simple 4 steps to complete:

  1. Create REST connection
  2. Create DB connection
  3. Create an Integration
  4. 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 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 the same 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 /)
    • Select HTTP verb
    • Select Configure a request payload for this endpoint checkbox- This option allows us to assign payload in the next step
  • Select Json Sample Radio button: This option allows us to take input in json format. Select inline link to give sample payload
  • Enter payload and click OK
  • Click Next and Done button
  • Click Invokes from right navigation, Select Oracle Databases, drag and drop the TEST_DB_Conn below PostEmployee
  • Enter below information and Click Next
    • Enter endpoint name 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
INSERT INTO apps.employee_info(employee_id, first_name,last_name,qualificatoin,designation) values(#employee_id,#first_name,#last_name,#qualification,#designation)

  • Click Done
  • Click on Map to InsertEmployee mapper and click Edit button
  • Map the source and target field as shown in the below scree shot. Click Validate and Close button
  • Select Action icon and click on Tracking. This is mandatory step and can’t activate integration without this step. Basically this allows us to track the Instance with configured parameter. In our case we will select employeeId field.
  • Drag & Drop the employeeId from left panel to first row in Tracking Field and click Done button
  • Click Save and Close button from upper right corner
Now our integration is completed and now turn to activate the integration.

      4. Activate Integration
  • Click on Activate button
  • Select Enable tracking and Include payload check boxes button. This option is useful if we want to see payload in the logs. Click Activate button
  • As soon as, integration will be activated, ICS will show you the service end point on the upper side as shown in the below screen shot. Alternatively, you can click on the info icon near to the activate button that will show you the service end point.

This is the time to test the service and see the data in database table. We will use POSTMAN tool to test the REST service

      5. Test the REST service

  • Open postman tool
  • Enter service end point
  • We have to add Basic Auth as ICS service is automatically secured. We need to provide ICS console credentials.
  • Enter payload and hit Submit button

  • Open database and see record should be inserted into the database
That's done !



Database Adapter in Oarcle ICS(Integration Cloud Service)

In this blog, we are gonna to explain  Oracle database adapter capabilities and how to connect Oracle Database that resides in on-premises network.

Oracle Database Adapter capabilities

The Oracle Database Adapter enables us to integrate the Oracle database residing behind the firewall of on-premises environment with Oracle Integration Cloud Service through use of the on-premises connectivity agent. We can also integrate Oracle database residing on the public cloud and don't require Agent in the picture.



The Oracle Database Adapter provides the following capabilities:
  • Invocation of stored procedures.
  • Support for non-JDBC (PL/SQL) datatypes in outbound invocations of stored procedures.
  • Support  of DML statements and SQL queries: Select, Insert, Update, and Delete.
  • Support for generating XSD from PureSQL. 
  • Polling for new and updated records for processing in the Oracle database. 
  • The Oracle Database Adapter supports distributed polling and multithreading. 
  • Support for a logical delete polling strategy. 
  • Support for database fault mapping
Connection with Oracle Database

In this we will show you how to make Oracle database connection using ICS that resides on on-premises environment.

Below are the pre-requisite to make DB connection
  • ICS agent should be installed(If not then follow the blog)
  • On-premise agent should be up and running(If not please follow the blog)
  • DB port should be opened on the ICS host machine

Let's create a DB connection in ICS
  • Login into the ICS console
  • Click on the Connection tile from the ICS home page
  • Click on Create button from upper right corner

  • Search Oracle Database and select Oracle Database adapter
  • Provide below information in the opened dialg box and Click on Create button
    • Name: Any meaningful name
    • Identifier: Identifier would be picked up automatically based on name, but we can edit.
    • Role: Select Trigger and Invoke. We can use this DB connection as a source or target both.
  • Click on Configure Connectivity, enter below information and click OK button
    • Host: Database host or IP
    • Port: Database port number
    • SID: Database SID

  • Click Configure Security, enter below and click OK button
    • UserName: Database user name
    • Password: Database password
    • Confirm Password: Database password
  • Click Configure Agent and select the available agent(TEST_AGENT_GROUP) that we created in our previous blog. Click on Use button
  • Click on Test button from upper right corner. If everything is correct then progress bar will reach to 100%
  • Click Save and Close button from upper right corner.
Now you are done and ready to use DB connection in your integration.

Kamis, 06 Juli 2017

Start, Stop & Deinstall ICS agent server

In my previous blog, we have learned how to install Oracle ICS agent on Linux server. As we have seen during ICS connectivity agent installation, it runs on Weblogic server. However we should not use startWebLogic.sh nor stopWebLogic.sh to start and stop on-premises agent.

Instead ICS agent provide another script startAgent.sh and stopAgent.sh to start and stop on-premises agent respectively. These two script resides inside the folder where we have installed the Agent.



Start ICS Agent

  • Login into the host machine where we have installed ICS agent
  • Set JAVA_HOME using export JAVA_HOME=/usr/java/jdk1.7.0_80
  • Move to the directory where ICS agent has been installed and see the files under this
  • See startAgent.sh exist in the directory. Hit the below command to start ICS agent
               nohup ./startAgent.sh -u=test@test.com -p=TEST@123 &

Where: -u= {User Name of ICS console} and -p={Password of ICS console}
  • As we have used the nohup command to start agent. Agent will be start in background. To see the output use below command
    • tail -500f nohup.out
  • Make sure server starts with a successful message


Stop ICS Agent

  • Login into the host machine where we have installed ICS agent
  • Set JAVA_HOME using export JAVA_HOME=/usr/java/jdk1.7.0_80
  • Move to the directory where ICS agent has been installed and see the files under this

  • See stopAgent.sh exist in the directory. Hit the below command to start ICS agent
               ./stopAgent.sh
  • Make sure server stop with a successful message

Deinstall ICS Agent

In order to deinstall ICS agent follow the below steps:
  • Stop ICS agent as shown in the previous steps
  • Delete the directory in which on-premises agent is installed
  • Now delete it from ICS console
    • Login into the ICS console
    • Click Agent tile from ICS home page
    • Find the Agent group
    • Click the number representing the agent count. The Agents in this Agent Group dialog is displayed.
    • Find the agent to delete, and click X to delete the agent registration.



ICS(Integration Cloud Service) On-Premises agent installation

This purpose of this blog is to show you how to install Oracle ICS On-Premises agent. The Oracle On-Premises Agent (aka, Connectivity Agent) is necessary for Oracle ICS to communicate to on-premise resources without the need for firewall configurations or VPN.


Below are the System Requirements before we start On-Premise agent installation.

  • Agent Group: Agent Group is required before we run the agent installer. When we install the on-premises agent in environment, we associate the on-premises agent with the agent group identifier. 
  • JDK: Install only Oracle JDK version 1.7 or 1.8. Other JDKs such as Open JDK are not supported.
  • Supported OS: Below OS are supported to install Oracle ICS agent
    • Linux OEL version 6 or 7
    • Red Hat Enterprise Linux Server release 6.6 (Santiago)
    • SUSE Linux Enterprise Server 12 SP1
  • Hardware Requirement: 8GB memory with 4 GB of heap size dedicated for the agent JVM
  • On-Premise Agent Installer: On-Premise Agent installer can be downloadedfrom Oracle ICS home page.
  • Internet Access: Either internet access or white-list the Oracle ICS public IP on the host where we'll install Oracle ICS agent.


Download ICS On-Premise Agent
  • Login into the Oracle ICS console
  • Click on the Agent tile from home page
  • Click Download and select Connectivity Agent: Installer is almost 1.7GB and may take time to install depending on your network speed.


Create an Agent Group

We must create an agent group in Oracle Integration Cloud Service before we can run the agent installer. When we install the on-premises agent in our environment, we associate the on-premises agent with the agent group identifier. Only one on-premises agent can be associated with an agent group. For a single Oracle Integration Cloud Service instance, we can create up to five agent groups. 

Follow the below steps to create Agent Group
  • Login into ICS console
  • Click on Agent tile from home page
  • Click on Create Agent Group
  • Enter Agent Group Name and Identifier. Additionally you can provide the meaningful description in the Description text box. Click on Create button

  • ICS Agent Group will be created


Install ICS On-Premise Agent
  • Login into the host machine
  • Set JAVA_HOME using export JAVA_HOME=/usr/java/jdk1.7.0_80
  • Set PATH using export PATH=$JAVA_HOME/bin:$PATH
  • Verify the JAVA_HOME and PATH variables using echo $JAVA_HOME and echo $PATH, these path must pointed to the exact java location.
  • Copy the ICS agent on any one of the location on the host where you want to install Agent
  • Unzip the installer
  • Locate the cloud-connectivity-agent-installer.bsx agent installer file
  • Make sure you must have executable permission to install the agent
  • Run below command
./cloud-connectivity-agent-installer.bsx —h=https://ICS_host.us.oracle.com:port —u=username —p=my_password —ad=agent_group_identifier -au=agent_username -ap=agent_password



Below table depicts the parameter that can be used during installation as per the requirement

Parameter
Required
Description
-h
Yes
Oracle Integration Cloud Service hostname and port. For example,  https:// test.integration.us2.oraclecloud.com:443
-u
Yes
Oracle Integration Cloud Service user name.
-p
Yes
Oracle Integration Cloud Service password.
-ad
Yes
Agent group identifier that was generated in the Identifier field when we created the agent group 
-au
No
This is a new username used to initialize the local installation of the on-premises agent. If not specified, the default username of weblogic is used.
-ap
No
Specify a password for the new agent username. If not specified, the default password is used. We may need to contact Oracle Support Services to obtain the default password for the default user weblogic.
—aport
No
Specify the agent port (for example, 9002). This enables us to specify any available port outside of the default value of 7001. If not specified, it defaults to 7001. Any free port can be used.
-ph
No
Hostname, or address, of the proxy server. The -ph and -pp properties are only required if your on-premises environment is set up with a proxy server mandating that all connections be routed through it.
-pp
No
Port number of the proxy server.
-pu
No
Proxy server user.
-ppw
No
Proxy server user password.
-nphosts
No
Nonproxy hosts:-nphosts=NONPROXYHOSTS. We can specify a single host or multiple hosts separated by a |. For example:
-nphosts=abc.com|xyz.com
-profile
No
Set the number of worker threads to a value appropriate to your environment.


Please wait, installation takes time. Once completed, check the logs at the same location from where you have ran the command.

During installation, the following tasks are performed:
  • All on-premises adapters are registered.
  • A Java database is installed.
  • The JRF domain is created.
  • The on-premises agent is deployed.

Once done you will get the successful message as shown in the below screen shot


Once installation is complete, an agent instance is created for interacting with Oracle Integration Cloud Service.

Verify that the agent instance was created by going to the Agent Groups page from ICS console and noting that the agent count was increased by one. If we click the number, details about the agent are displayed.


We are now ready to create an adapter connection in Oracle Integration Cloud Service that uses the on-premises agent.

Blog will show you how to start, stop and Deinstall Oracle ICS agent


Create a REST connection in Oracle ICS

In this article we will show you how to create REST connection that might be used to create REST service.

Related blogs


Below are the simple steps to create REST connection
  • Login to the ICS console
  • Move to the home page
  • Click on Connection
  • Click on Create button from upper right corner
  • Search REST and select REST Adapter


  • Enter Name as TEST_REST_Conn and select Trigger from Role type drop down. We have selected Trigger as we want to expose this REST connection as a REST service. Means this will work as an endpoint for the end user
  • As this is the Trigger REST connection, you don't need to configure anything in this. Leave all as it is. And click on Test button in the upper right corner. If everything goes fine, progress bar will reach 100%
  • Click Save and close button from upper right corner

Selasa, 04 Juli 2017

Salesforce Adapter in Oracle ICS(Integration Cloud Service)

Integration Cloud Service provide a powerful adapter that is called Salesforce adapter being used to create connection with Salesforce CRM application.

The Salesforce adapter provides the following advantages:


  • Integrates easily with the Salesforce application’s WSDL file to produce a simplified, integration-centric WSDL.
  • Contacts the Salesforce application to fetch metadata information about business objects.
  • Provides invoke (outbound) support for using a custom WSDL that includes custom Apex classes exposed as SOAP web services.
  • Provides trigger (source) messaging support for objects through use of the Salesforce outbound messaging WSDL.
  • Provides trigger (source) callback support.
  • Provide invoke support for CRUD (create, get, update, and destroy) operations
  • Provide invoke support for Salesforce Object Query Language (SOQL) or Salesforce Object Search Language (SOSL) query operations
Below is the pre-requisite to start the SFDC connection
  • Salesforce account credentials
  • Salesforce Enterprise WSDL
Let's suppose we already have a SFDC credentails and try to get the Enterprise WSDL.

Below are the steps to generate the Enterprise WSDL:
  • Login into the SFDC
  • Click on the User name from the upper right corner

  • Enter API from search box and Select API
  • Click on Generate Enterprise WSDL
  • Click on the Generate button

  • Save WSDL

Now we have SFDC Enterprise WSDL in place. Let's create SFDC connection in ICS.


Follow the steps to create SFDC connection.
  • Login into the ICS
  • Click on the Connection
  • Click on Create button
  • Search Salesforce and Select Salesforce adapter

  • Enter Name and select Trigger/Invoke as a Role basis on your requirement and Click Create button
  • Select Configure Connectivity button. Select the enterprise WSDLthat we have saved in the above steps during getting Enterprise WSDL and click OK

  • Click Configure Security button, and enter SFDC Username and password and click OK button
  • Click on Test button and Validate and Test button from the popup
  • If everything goes fine then progress goes to 100% as shown in the below screen shot
  • Click Save and Close button

Now we are done with the SFDC connection and ready to use in our integration.


Minggu, 21 Mei 2017

Serve static resources from external folder outside webapps tomcat

This is quite an important blog for all folks who is looking on how to serve static content from a location on a disk which is completely outside of the webapps folder in Apache Tomcat. This method is quite useful to server images, JS, CSS, PDFs and even static HTML web pages.

Tomcat will serve any static content from a WAR file using the DefaultServlet. This works great for serving files that are bundled with your Java code inside of a WAR file – it’s fast enough for most purposes and it just works, but with one major drawback: you have to re-deploy the WAR file if you want to add or amend a static file.

Tomcat can be configured to read files from anywhere on the disk and serve on a specific URL. This configuration is completely separate to our application configuration.

You just need to change a single file server.xml that resides under $CATALINA_HOME/config/server.xml.

Just open the server.xml file and make the changes like below.

Remember: You need to take bounce of server after the making the changes to take effect of the changes.

<Host name="localhost"  appBase="webapps"
unpackWARs="true" autoDeploy="true">

<Context docBase="C:\Ankur\testFiles" path="/companyLogo" />

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t &quot;%r&quot; %s %b" />

</Host>

A <context>  element is added inside the <HOST>  element. Context has two attributes: docBase is the directory on disk that contains your static files and path is the URL that you want to serve the files on. 

Make sure that Tomcat has access to read the files in docBase. Using the example server.xml snippet above, if we had an image in C:\Ankur\testFiles called test.png then we would be able to access it via local Tomcat instance using http://localhost:8081/companyLogo/test.png.

Let's see the example below:

1) Put files inside the C:\Ankur\testFiles directoy

2) Hit the URL: http://localhost:8081/companyLogo/7.png and see the result:




That's it !!