Saturday, 14 December 2013

Implementing FTP Put in Oracle Soa 11g




Hi Guys

 lets discuss How to write a file through FTP read Using FTP in my previous Post.
Continues  to the FTP Read post


How to create a BPEL process using an FTP Adapter service

1. Navigate to the “Component Palette” and select “Services” option. Services palette enlists all the services options available which can be used to invoke another service or system using either partner links or Adapters.

2. Now drag the “FTP Adapter” and drop it in the Reference swim-lane of the BPEL process, an Adapter Configuration Wizard appears. Click next to go the next window. In step 1, specify a desired name to the adapter and then click next to go the next window



3.In Step 2, specify the JNDI name of the FTP Server.
The JNDI name of a resource and the name of the resource reference are not the same. This approach to naming requires mapping of the two names before deployment, but it also decouples components from resources. Because of this decoupling, if at a later time the component needs to access a different resource, you don't have to change the name in the code.
(Read “How to configure the JNDI in Application server console” at the end of
the section)
After specifying all the required information, click next to go to the next window

4 .In the next step, select the operation as per requirement to create FTP adapter for. Select the radio button “Put” to create an adapter to read a file and click next to go to the next window. In FTP Adapter, an additional operation is also supported where the user can select if the file is of ascii type or binary type. The user can select the radio button”Ascii” if the file is of ascii type, else select the radio button “Binary” as per the requirement.




  5. In the next step, specify the path of the incoming file.
Location of the path can be specified in two ways 1) Physical path and 2) Logical path.
Physical path is the absolute location of the file where it is located. This specified directory should be accessible to the server.
Logical path is the location of the file relative to the current location of the file adapter on server.
Default option is “Physical path”





File Naming Convention (PO_%SEQ%.txt) specifies pattern for writing  file
for example :Sample_%SEQ%.xml

files will be written 
Sample_1.xml
Sample_2.xml
Sample_3.xml
Sample_4.xml  ...............



6.  In the next Step, specify the name of the file from where the data need to be retrieved.
File names can be specified using two options, 1) File Wildcards and 2) Regular Expressions.
“File Wildcards” allows user to specify file having a similar naming pattern like po*.txt where * can be replaced by any character or digit or symbol.; whereas “Regular Expressions” can be used for normal search where in it searches for the file having similar string pattern.

User can also specify the naming pattern of the files which needs to be excluded (if any) from the reading operation.

“Files contain multiple Messages” can be checked if the incoming file is expected to have more than one message. Number of messages needs to be retrieved in batches if the incoming file having multiple messages can also be specified. Default number is “1”





6.The next window prompts to select a schema format for the data to be retrieved.
Select a schema which already exists in the project (if any) or create a new schema format using a sample data file. Click next to go to the next window. 



Click “Finish”. Click “Apply” and “OK” on the “Create partner link” window to end the process of creating an adapter





We are Ready to Write File  to FTP ,Deploy and test your service


HappyLearning



                                                                                                                                                 By DeepthiReddy

Implementing FTP Adapter in Oracle Soa 11g



Introduction to FTP Adapters
While working on integration projects particularly involving legacy systems, many times there is requirement to get a flat-file or a CSV (Comma Separated Values) from a remote server and then process it as XML or file using some delimiters and use this file or write the XML data into another file. This can be achieved by Java code.
Oracle BPEL provides “FTP Adapters” to achieve these functionalities. FTP adapter can be treated as a service which provides following operations from a remote server.
1.Get a file from a remote server
2.Put a file to a remote server
3.Synchronous Get or Get a current file.
“Get” operation can be used when requirement is to poll on a particular location or directory at particular intervals and once file with name specified as available process it. This operation also provides an option to delete or to achieve a processed file.
“Put” operation can be used to write the data into a file at a particular location. The same operation provides option to append data to an existing file and once a particular size is exceeded create another file.
If requirement is to read data from a file at a location which can be dynamically specified, then “Synchronous Get” operation can be used. Following section gives the difference between “Get” operation and “Synchronous Get” operation.
Difference between Get Adapter and Synchronous Get Adapter
1.“Get” operation in FTP Adapter polls the given input file periodically according to the frequency given, that is, it tries if the file is available at given location after a specified interval waits until the given file doesn't exist. Once file is available it starts processing it by creating an instance of the BPEL process. Whereas “ Synchronous Get” operation in FTP Adapter reads the file only when the instance is triggered and it does not create the instance on its own, Neither it polls on particular directory
2.FTP Adapter with “Get Operation” can be invoked only using “Receive Activity” whereas for “Synchronous Get” Operation of the FTP adapter has to be invoked using “Invoke Activity”


How to create a BPEL process using an FTP Adapter service

1. Navigate to the “Component Palette” and select “Services” option. Services palette enlists all the services options available which can be used to invoke another service or system using either partner links or Adapters.

2. Now drag the “FTP Adapter” and drop it in the services portion of the BPEL process, an Adapter Configuration Wizard appears. Click next to go the next window. In step 1, specify a desired name to the adapter and then click next to go the next window



3.In Step 2, specify the JNDI name of the FTP Server.
The JNDI name of a resource and the name of the resource reference are not the same. This approach to naming requires mapping of the two names before deployment, but it also decouples components from resources. Because of this decoupling, if at a later time the component needs to access a different resource, you don't have to change the name in the code.
(Read “How to configure the JNDI in Application server console” at the end of
the section)
After specifying all the required information, click next to go to the next window

4 .In the next step, select the operation as per requirement to create FTP adapter for. Select the radio button “Get” to create an adapter to read a file and click next to go to the next window. In FTP Adapter, an additional operation is also supported where the user can select if the file is of ascii type or binary type. The user can select the radio button”Ascii” if the file is of ascii type, else select the radio button “Binary” as per the requirement.



  5. In the next step, specify the path of the incoming file.
Location of the path can be specified in two ways 1) Physical path and 2) Logical path.
Physical path is the absolute location of the file where it is located. This specified directory should be accessible to the server.
Logical path is the location of the file relative to the current location of the file adapter on server.
Default option is “Physical path”
Options either to archive processed files or delete files after successful processing of file can be specified using options Available.
There might be requirement to save the files after processing the data from it. In such conditions, these files can be achieved to by checking the box “Archive processed files” in this window. The path of the directory where the processed files have to be saved (or archived) after processing can be specified. Again this path can be either absolute or logical based on the option selected earlier.
Instead, at times the files after retrieving the data from the file need to be deleted. This can be achieved by checking the box “Delete files after successful retrieval” in this window.
After specifying all the required information, click next to go to the next window.



6.  In the next Step, specify the name of the file from where the data need to be retrieved.
File names can be specified using two options, 1) File Wildcards and 2) Regular Expressions.
“File Wildcards” allows user to specify file having a similar naming pattern like po*.txt where * can be replaced by any character or digit or symbol.; whereas “Regular Expressions” can be used for normal search where in it searches for the file having similar string pattern.

User can also specify the naming pattern of the files which needs to be excluded (if any) from the reading operation.

“Files contain multiple Messages” can be checked if the incoming file is expected to have more than one message. Number of messages needs to be retrieved in batches if the incoming file having multiple messages can also be specified. Default number is “1”



7.Select polling frequency and minimum file age accordingly.
“Polling frequency” is the interval after which the adapter needs to poll the file periodically to receive the data.
“Minimum File age” is the minimum time adapter should wait, after the file is created. In other words,”Minimum file age” refers to the time elapsed between the file creation and next run of the polling frequency.
Click next to go to the next window


8.The next window prompts to select a schema format for the data to be retrieved.
Select a schema which already exists in the project (if any) or create a new schema format using a sample data file. Click next to go to the next window. 



Click “Finish”. Click “Apply” and “OK” on the “Create partner link” window to end the process of creating an adapter


Now create a Receive which will be listening to Incoming files from  FTP.
Deploy the process to the server and the process itself creates an instance. Check the “Flow” and “Audit” of the instance. The input file is read and transformed to XML format. For example, if the input file contains the data “Hello,BPEL,Process”, it will be transformed as shown below.


HappyLearning

                                                                                                         By DeepthiReddy




Thursday, 12 December 2013

Implementing Date Functions in BPEL


date functions  Usage in Oracle BPEL

Format-dateTime:

This function returns the formatted string of dateTime using the format provided.

xp20:format-dateTime(dateTime as string, format as string)

  •   dateTime – The dateTime to be formatted
  •    format – The format for the output
Format String:-

Format Date Time: Year

Example
Expression
2012
[Y0001]
2012
[Y]
12
[Y01]
Two Thousand and Twelve
[YWw]

Format Date Time: Month

 Example
Expression
08
[M01]
8
[M]
VIII
[MI]
August
[MNn]
AUGUST
[MN]
Aug
[MNn,*-3]
AUG
[MN,*-3]

                                      
Format Date Time: Day

Example
Expression
05
[D01]
5
[D]
5
[D1]
31st
[D1o]
Tuesday
[FNn]


Format Date Time: Hour

Example
Expression
3
[h]
9
[H]
08
[H01]


Format Date Time: Minute
Example
Expression
03
[m01]
3
[m]

Format Date Time: Second
Example
Expression
09
[s01]
9
[s]

Format Date Time: Millisecond
Example
Expression
257
[f001]

Format Date Time: AM/PM
Example
Expression
PM
[PN]
Am
[Pn]


Format Date Time: GMT
Example
Expression
GMT+02:00
[z]


Example:-

xp20:format-dateTime(xp20:current-dateTime(),"[D01]/[M01]/[Y0001] [H01]:[m01]:[s01]")

add-dayTimeDuration-from-dateTime:

This function returns a new date time value adding dateTime to the given duration.
If the duration value is negative, then the resulting value precedes dateTime.

xp20:add-dayTimeDuration-from-dateTime(dateTime as string, duration as string)
  • dateTime as string – The dateTime to which the function adds the duration, in string format.
  • duration as string – The duration to add to the dateTime, or subtract if the duration is negative, in string format.
Duration:-

    P1D - a day
    P7D - a week
    P1M - a month
    P1Y1DT1H1S - One year, one day, one hour and one second
    PT5M - five minutes
Example:-

xp20:add-dayTimeDuration-to-dateTime(xp20:current-date(), 'P1D')

subtract-dayTimeDuration-from-dateTime:
This function returns a new dateTime value after subtracting duration from dateTime.
If the duration value is negative, then the resultant dateTime value follows input-dateTime value.

xp20:subtract-dayTimeDuration-from-dateTime(dateTime as string, duration as string)
  • dateTime as string – The dateTime from which the function subtracts the duration, in string format.
  • duration as string – The duration to subtract to the dateTime, or add if the duration is negative, in string format.

Duration:-

    P1D - a day
    P7D - a week
    P1M - a month
    P1Y1DT1H1S - One year, one day, one hour and one second
    PT5M - five minutes

Example:-
xp20:subtract-dayTimeDuration-from-dateTime(xp20:current-date(), 'P1D')
Testcases
My current requirement to change   Bpel date format to database timestamp

example:  2014-05-31  TO  31-MAY-14

 <xsl:value-of select="xp20:format-dateTime(ns0:PWSENROLLDATE,'[D01]-[MN,*-3]-[Y01]')"/>





HappyLearning

                      
                                                                                                               By DeepthiReddy

Wednesday, 11 December 2013

Writing File Through OSB File Protocal

Hi Guys.

In this post I will explain you how to write file  in OSB.

Follow below step to write file in OSB.


Step 1.) Create new OSB project and Business Service.

  • First Create a session and then click on "Project Explorer".
Create New project
  • Add new project with the name "WriteFile".
Write File Project
  • Now click on newly created project to add new folder.
Add Folder
  • Add new folder inside "WriteFile" project with name "businessService".
business Service Folder
  • Now click on "businessService" folder to create business service and choose "Business Service" as "Resource Type".
Choose Resource Type

Step 2.) Fill details in Business Service.
  • Enter Business service name and choose "Service Type" as "Messaging Service". Click on "Next" button.
Name Business Service
  • Choose "Request Message Type"  based on what type of file you want to write.In my case it is text file so I will choose "Text". Choose "Response Message Type" as "None" as we don't need any response after writing the file.
Choose Message Type

  • Choose "file" protocol from drop down list.
file Protocol
  • Provide the "Endpoint URI" and click on "Add" button.
              file:///{Dirve Id}/filedir/

EndpointURI
  • Provide File Transport Protocol details. Click "Next".
Fill File Name

Accept all default values and save Business Service. Now your Business Service is ready to write text file. 


HappyLearning

                                                                                                                      By DeepthiReddy


 

Reading File Through OSB File Protocal

Hi Guys


Lets Understand how we can read file through OSB. This post explains how you can read file in OSB.

Follow below steps to read file in Oracle Service Bus.


Step 1.) Create new OSB project and Proxy Service.

  • First of all create Session by clicking on "Create" Button and then click on "Project Explorer" to create new project.
Create Session
  • Enter the name of the project "ReadFile" and add it.
Create New Project
  • Now click on newly created project "ReadFile" to add new folders.
Read File Project
  • Add "proxyService" folders which contains proxy service that will poll/read the file from given location.

Proxy Service
  • Now click on newly created "proxyService" folder to create proxy service and choose "Proxy Service" as Resource Type.
Service Resource Type

Step 2.) Fill details in Proxy Service to read/poll file.
  • Enter proxy service name and choose "Service Type" as "Messaging Service". Click on "Next" button.



Proxy Service name and type


  • Choose "Request Message Type" based on what type of file you want to read/poll. In my case its text file so I will choose "Text". Choose "Response Message Type" as "None" because we don't need any response after reading the file. Click on "Next" button.
Request Message Type
  • Choose "file" protocol from drop down list.
file protocol
  • Provide the "Endpoint URI". Click on "Next" button.
                   file:///{Drive Id}/filedir/


file directory
  • Next step is to provide File Transport Protocol details. 
    • File Mask: Default value is *.* that means you can send any type of file to the service. I created "test.txt" file in C:/read directory for this post.
    • Polling Interval: It specifies the number of seconds between each polling event. Leave it as default.
    • Read Limit: It specifies the maximum number of files to process during each polling event.Default value is 10. If you set it to 0 that means all files that match the file mask at the time of polling event will be processed. Leave it as default.
    • Sort By Arrival : It forces the selection of files while polling based on their creation date. Remain it unchecked.
    • Scan SubDirectories: It says OSB proxy look for files recursively in any existing subdirectories. Leave it unchecked.
    • Pass By Reference : It tells copy the file to archive directory and pass a reference to the file in the message itself. Leave it unchecked.
    • Post Read Action: It tells we can either delete the file or archive the file after the message has been processed. Choose "delete" for this sample.
    • Stage Directory : It specifies where the files should be stored while they are being processed. So while polling, OSB first move file from polling directory to stage directory and process file from there.
    • Archive Directory : Directory where we want to archive the file. This will not be available if you choose "delete" as Post Read Action.
    • Error Directory: Directory where file will be sent of there is any problem or issue. 
File Transport Protocol Properties
  • Accept default values and you are done with your proxy service. 
  • Activate the session and to test proxy service put test.txt file in C:/read directory.

refer site : http://www.oracle.com/technetwork/articles/soa/schmutz-osb-cookbook-1543518.html


HappyLearning


                                                                                                                            By DeepthiReddy