Thursday, 2 February 2012

Configuring FTPAdapter in Oracle SOA 11g


Configuring FTP adapter in oracle SOA suite 11g:


In this post, we are going to see how to user FTP adapters in Oracle SOA Suite 11g.We will also see how to configure a single FTP adapter for multiple hosts.Without further ado, let us get started.

First, we are going to install and configure an FTP server locally.I am going to use FilleZilla.You can download the FileZilla Server from :

                               http://filezilla-project.org/download.php?type=server


Download and install the program.When first time you run the program, a screen like the following image pops up.

Accept the defaults and hit OK.Next, we are going to add a user.To do this, click on the add user icon as indicated in the image below:-



On the "Page" pane on the left, select the "General" node.Next click on the "Add" button to add a user :-



Next, in the "Add user account" window that pops up, enter a name for the user account.To follow along, enter "user".Leave the other defaults and hit OK.



Notice that the user has been added to the list of users.Click on the password checkbox and enter a password for your account.To follow along, enter 'password1$'.



Next, click on the "Shared folders" node under the page pane.



Hit the "Add" button under the "Shared Folders" pane as indicated in the image below:



In the "Browse for Folder" window, select a location.To follow along, select "C:\temp".



Back in the "Users" window, make sure you check the "Write" check box to provide write permission.


Hit OK once you are done.



In the next step, we are going to configure an outbound connection pool in the weblogic FtpAdapter application.This is necessary to make this whole thing work.First start up the weblogic admin server and the managed SOA server.Next go to the weblogic console.Next click on the "Deployments" link as indicated in the image below:-



On the deployments page, click on the "FtpAdapter"  application.(You may not see the adapter on the first page of the list.In this case, click on the "next" link on the top right to navigate through the pages until you see it).



In the next page, select the "Configuration" tab and then under "Configuration" tab, select the "Outbound Connection Pool" tab.



Next click on the new button as indicated in the image below:-



On the next screen, select the "javax.resource.cci.ConnectionFactory"  radio button and hit next.




In the next screen enter a JNDI name of your choice.To follow along, enter "eis/Ftp/test".Make a note of this JNDI as we will be needing it not too far from now.Hit the "Finish" button once you are done.



This will get you back to the "Outbound Connection Pool Configuration Table" page.Expand the "javax.resource.cci.ConnectionFactory" node.You will be able to see the the JNDI of the connection factory that we just created.




Click on the connection factory to configure the properties.We are going to set the following properties:-

                              host
                              port
                              username
                              password

You will not see all the properties in the same page.To locate them, you will have to navigate through the list by clicking on the Next and Previous buttons at top-right or bottom right of the table.



To set the properties, you must follow the following steps in sequence:-

                a. Locate the pertinent property.
                b. Click on the particular cell for that property under the "Property Value" column.
                c. Type in the value and hit Enter.

Following these steps, locate the "Host" property and set the value to "localhost".Set the "port" to "21".Set username to "user" and password to "password1$".Hit the save button once you are done.



Next click on the "Deployments" link to go back to the "Deployments" page.In the "Deployments" page, select the checkbox next to the "FtpAdapter" application and click on the "Update" button as indicated in the image below.




In the page that appears next, accept the defaults and click on the finish button.


If everything goes right, a success message is going to be displayed on top of the screen.



This completes our configuration for the "FtpAdapter".

Next, open JDeveloper.I am using JDeveloper 11.1.1.5.If you are using an older sub-version, dont't worry because the steps are going to be the same.

First, click on File and select the new option



In the "New Gallery" , select the "Applications" node under "General" tab in the left pane and on the right pane, select the "SOA Application" option.Hit "OK" once you are done.



In the next screen, enter a suitable name for the application.To follow along, enter "FTPTest".Hit next once you are done.



In the next screen, enter a suitable name for the project.To follow along, enter "FTPAdapterDemo".Hit next once you are done.


In the next screen, select the option "Composite with BPEL Process" option and hit "Finish".


The dialog for creating BPEL process will pop up.Enter a suitable name for the BPEL process.To follow along, enter "FTPDemoProcess".Select one-way as the process template.Leave the other defaults as they are.Hit OK once you are done.


The BPEL process is going to be added to the composite and the composite should now look somewhat like the following image:



Next drag and drop a File Adapter from the component palette to the "External References" swim lane.Once you do that, the "FTP Adapter Configuration Wizard" is going to open.Click next on the first screen that appears.




In the next screen that appears, enter a service name.To follow along, enter "FtpAdapterService" as the service name.Hit next once you are done.



In the next screen, select the option "Define from operation and schema (specified later)" option and hit next.



In the next screen, enter the JNDI name of the connection factory that we created previously.If you followed along, that is "eis/Ftp/test".


In the next screen, select the "Put File" operation as we want to write a file.Notice that the operation name is also automatically changed to "Put".Also, select the "Ascii" option as the File Type.Hit next once you are done.


In the next screen, choose the "Physical Path" option and enter "." in the "Directory for Outgoing Files( Physical Path)" text box.Enter a file naming convention.To follow along, enter "test_%SEQ%.text".Leave the other defaults as they are and hit next.



In the next screen, click on the magnifying glass as indicated below to select the schema file.


In the new window that pops up, expand the "Project Schema Files Node" and select the "process" node under the "FTPDemoProcess.xsd" node.Hit OK once you are done.


Back in the "FTP Adapter Configuration Wizard", select next.


In the next screen, hit Finish to complete the creation of the FTP adapter.



The composite should look somewhat like the following image:-



Next, wire the BPEL process with the FTP adapter that we created.


Next, double click on the BPEL process to open it.Next drag and drop an assign activity after the default "Receive" activity.Next drag and drop another "Invoke" activity just after the assign activity.Next, double click on the invoke activity.In the screen that appears, enter a name for the activity.To follow along, enter "InvokeFtpAdapterService".Then click on the magnifying glass as indicated in the image below:




The "Partner Link Chooser" window will pop up.Select the "FtpAdapterService" partner link and hi OK.



Back in the previous screen, click on the green plus icon as indicated in the image below to create the input variable for the invoke activity.


In the "Create Variable" window, select the defaults and click on O

Back in the previous screen, verify the configuration and once you are satisfied, hit OK.



Next double click on the assign activity and select the "General" tab.Enter a name of your choice.To follow along, enter "AssignInput".

 

Next, select the "Copy Rules" tab and create a copy operation from the input variable to the to the input variable of the invoke activity.You can use the following image as a guide.Hit OK once you are done.


The BPEL process should look like the following image:-


Next deploy and test the process.A file should be written in the C:\temp directory.


Configuration to use multiple FTP Hosts:


Think of the scenario that you want to write your files to a different location based on some condition.We can achieve this in the following way:

First configure another connection pool in the outbound connection pool and configure your host.For testing purpose, I configured another user in FileZilla with a different directory location.Then used the username and password of that user to configure another connection factory.The name of the connection factory that I configured is "eis/Ftp/FtpAdapter".I shared the folder "D:\ftp" for this user.

Now, open the BPEL process and create a new global variable by clicking on the create variable icon as indicated in the image below:-



In the window that pops up, click on the green plus icon as indicated in the image below:-



In the create variable window,enter a name for the variable.To follow along enter "connFactory".Next, click on the magnifying glass beside the Type to select the type of the variable.




In the "Type Chooser" window, select string and hit OK.




Hit OK two times to complete the creation of the window.

Next, go to the source of the BPEL process by clicking on the source tab at the bottom:-


Next, modify the code for the invoke activity by specifying a reserved header property :- jca.jndi in the following way.



 <invoke name="Invoke_FtpAdapterService" bpelx:invokeAsDetail="no"
            inputVariable="Invoke_FtpAdapterService_Put_InputVariable"
            partnerLink="FtpAdapterService" portType="ns1:Put_ptt"
            operation="Put">
            
          <bpelx:inputProperty name="jca.jndi" variable="connFactory"/>  
           
    </invoke>



What this basically does is that it specifies the JNDI name of the connection factory to use at run time.

Now, go back to the Design view of  the BPEL process by clicking on the "Design" tab at the bottom.



Next, drag and drop a switch activity onto the BPEL process just after the assign activity.The BPEL process should look like the following image:-

 o
Next, double click on the switch activity.In the window that comes up, enter a name for the switch activity.To follow along, enter "SwitchConnectionFactory".Hit OK once you are done.


Next, click on the <condition> node for the case branch.Enter a label of your choice.To follow along, enter "tempdir".Next open the Expression Builder by clicking on the icon as indicated below:-


In the expression builder, enter the following XPath expression which checks the length of the input.

string-length(bpws:getVariableData('inputVariable','payload','/client:process/client:input'))>10


 Hit OK once you are done.







Next drag and drop an assign activity under the case branch of the switch activity.Drag another assign activity under the otherwise branch.The BPEL process is going to look like the following image.








Double click on the connection factory that is under the case branch.Go to the general tab and enter a name.To follow along, enter "AssignCF".


Click on the "Copy Rules" tag.Next create a copy operation that copies the string "eis/Ftp/test" to the "connFactory" variable.



The assign activity should look like this in JDeveloper 11.1.1.5.


Hit OK once you are done.

Next, double click on the assign activity under the otherwise branch of the switch.Go to the "General" tab and select enter a name.To follow along, enter "AssignCF".Next go back to the "Copy Rules" tab.Create a copy operation that copies the string "eis/Ftp/FtpAdapter" to the variable "connFactory".Hit OK once you are done.



The BPEL process should roughly resemble the following image:-


We are done.Deploy the process and test.If the length of the input is greater than 10 characters, then the file is going to be written in "C:\temp".Otherwise, it is going to be written in "D:\ftp".


Finally ..Enjoy with SOA...!!!

Configuring DBAdapter in SOA 11g


Establish a DBAdapter Deployment Plan Directory 


* Create a directory on the host machine where the deployment plan for the DbAdapter application can be saved.
* This only needs to be done once.
* Example:

Command: mkdir /opt/oracle/Middleware/home_11gr1/Oracle_SOA1/soa/DBPlan
(OR) 
Go to SOA installed home directory (.../home_11gr1/Oracle_SOA1/soa) and create DBPlan folder manually .


Acquire Change Lock :

* Click Lock & Edit button in the Change Center pane.

1) Create a Data Source:


* Follow below steps to create a Data Source to point to your database.
* Example:
- Name: myDS
- JNDI Name: jdbc/myDS




Login Admin Console.
* In Domain Structure pane, click soa_domain -> Services -> Data Sources.


* In Summary of JDBC Data Sources -> Configuration page, click New -> Generic Data Source.


* In JDBC Data Source Properties screen, enter:
- Name: myDS
- JNDI Name: jdbc/myDS
- Database Type: Oracle


* Click Next
* Select
- Database Driver: Oracle's Driver (Thin XA) for Instance connections; Verions:9.0.1 and later
- Click Next.
* Click Next on Transaction Options screen.
* On Connection Properties screen, enter:
- Database Name: orcl
- Host Name: localhost
- Port: 1521
- Database User Name: scott
- Password: tiger
- Click Next.
* On Test Database Connection screen, click Test Configuration button. Make sure the response is Connection test succeeded.


* Click Next.
* On Select Targets screen, select the target server instance. For example,


* Click Finish.



2) Create an Outbound Connection Pool:


* Click soa_domain > Deployments in Domain Structure pane.
* Click DBadapter in Summary of Deployments pane.
* Click Configuration -> Outbound Connection Pools tab.
* Click New button.


* Select javax.resource.cci.ConnectionFactory and click Next.


* Enter
JNDI Name: eis/DB/myDB


* Click Finish.

Assign Data Source to Connection Pool:


* Click Configuration tab -> Outbound Connection Pools tab.
* Expand javax.resource.cci.ConnectionFactory.
* Click the newly created outbound connection pool, e.g eis/DB/myDB.


* Click Properties tab and enter
xADataSourceName: jdbc/myDS
* Hit Enter key.
* Click Save button.

3) Redeploy DbAdapter :


* Click soa_domain > Deployments in Domain Structure pane.
* Click thecheckbox to select DBAdapter.


* Click Update button.
* Select Redeploy this application using the following deployment files
* Check deployment plan file is correct:
- Deployment plan path:/opt/oracle/Middleware/home_11gr1/Oracle_SOA1/soa/DBPlan/Plan.xml


* Click Next.
* Click Finish.

Activate Changes:


* Click Activate Changes button in the Change Center pane.

Finally ,..Enjoy with SOA 11g...!!!

Monday, 30 January 2012

SOA BPEL Transaction Recovery Steps(It would be useful in FTP Integrations)



The BPEL Console is a dashboard for tracing all transactions that flow through the middleware SOA server.
To retrieve the failed transactions for the BPEL call (E.g : WelcomeBPEL),

1)Login into the BPEL Console.
After entering the userid and password, click on the login button. Once logged in, you should see a dashboard screen.

2)Click on the Adminstration tab on the far top right.

3)Then click on the Recover Invokes tab
This brings you to the BPEL Recovery Page. From the dropdown on the left ,select the WelcomeBPEL call and click on the Search button.
Any transactions that appear on the right after the search button is clicked are incomplete transactions which need to be re-submitted.

4)Each transaction should be re-submitted one at a time by clicking the checkbox to the left of the transaction,Then hitting the “Recover” button at the bottom of the page.
A message will popup that the “Invocation Messages Scheduled”. This implies that the transaction has been re-submitted.
Click on the “Back to Recovery List” to go back to the Recovery Console to process any remaining transactions.

After re-submitting the transaction, you should see successfull instance in the Instances tab.

Finally , Enjoy with SOA BPEL..!!!

Installation steps for SOA Suite 11g & OSB (11gPS3) on Windows7 64 bit OS



Following installation steps would be useful to all of us.

I had installed SOA Suite 11g many times on various environments and If you are going to install the SOA Suite 11g then have a look at the below steps for the calrification:


SOA PS3 11.1.1.4 Installation with SOA 11g & OSB:-

1)Installing the Oracle XE:

OracleXEUniv.exe

sys/welcome1

and then tune the DB by using the below SQLs

connect sys/welcome1@XE as sysdba
show parameter session
show parameter processes
alter system reset sessions scope=spfile sid='*';
alter system set processes=300 scope=spfile;
shutdown
startup
show parameter session
show parameter processes

2)Installing the Weblogic Server:

Installable should contais the WLS + Coherence + OEPE

wls1034_oepe111161_win32.exe

3)Creating the schemas using RCU:

ofm_rcu_win_11.1.1.4.0_disk1_1of1.zip

Please must set the below property before running RCU

E:\FMW\PS311114\ofm_rcu_win_11.1.1.4.0_disk1_1of1\rcuHome\BIN>
set RCU_JDBC_TRIM_BLOCKS=TRUE
echo %RCU_JDBC_TRIM_BLOCKS%

E:\FMW\PS311114\ofm_rcu_win_11.1.1.4.0_disk1_1of1\rcuHome\BIN>rcu.bat

Schema users -Password: welcome1

4)Installing the SOA Suite:

ofm_soa_generic_11.1.1.4.0_disk1_1of2.zip
ofm_soa_generic_11.1.1.4.0_disk1_2of2.zip

Extract above zip files and go to below path (../Disk1) and Run the setup file by providing jdk160_21 path.

E:\FMW\PS311114\ofm_soa_generic_11.1.1.4.0_disk1_1of2\Disk1>setup.exe -jreLoc E:\FMW\Oracle\Middleware\jdk160_21


5)Installing the OSB:

V24316-01.zip -Extract this and go to the below path (../Disk1) and Run the setup file by providing jdk160_21 path.

E:\FMW\PS311114\osb\V24316-01\Disk1>setup.exe -jreLoc E:\FMW\Oracle\Middleware\jdk160_21

6) Configuring SOA & OSB:

E:\FMW\Oracle\Middleware\oracle_common\common\bin>config.cmd

7)Installing the JDeveloper:

Run the jdevstudio11114install.exe setup file.

E:\FMW\PS311114\jdevstudio11114install.exe

Extend SOA Compositor:

Open the Jdevloper and go to Help-->Check for updates -->Select the below SOA extension from your local system.

E:\FMW\PS311114\soa-jdev-extension.zip

Finally Enjoy with SOA 11g ...