Sei sulla pagina 1di 27

Configuring FTP adapters in oracle SOA suite 11g

Hi,
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".

Hope this helps.

Potrebbero piacerti anche