Saturday 25 October 2014

File Adapter MOVE operation in Oracle SOA 11g

File Adapter MOVE operation in Oracle SOA Suite 11g

The Oracle File and FTP Adapters let you copy or move a file from one location to another, or delete a file from the target directory. Additionally, the Oracle FTP Adapter lets you move or copy files from a local file system to a remote file system and from a remote file system to a local file system. This feature is implemented as a interaction specification for outbound services. So, this feature can be accessed either by using a BPEL invoke activity or a Mediator routing rule.

Step 1 :
Drag drop file adapter in reference pane of composite.xml

Setp 2:
In file adapter wizard perform below steps.

In wizard step4 we have to select Synchronous Read File
NOTE : You have selected Synchronous Read File as the operation because the WSDL file that is generated because this operation is similar to the one required for the file I/O operation.

provide your own name as per naming convention which you follow.
In my case i provided "FileMove" as move operation name.

Enter a dummy physical path for the directory for incoming files, and then click Next. The File name page is displayed.
Note: The dummy directory is not used. You must manually change the directory in a later step.

Enter a dummy file name, and then click Next. The Messages page is displayed.

Note: The dummy file name you enter is not used. You must manually change the file name in a later step.
Select Native format translation is not required (Schema is opaque), and then click Next. The Finish page is displayed.
Note: we are planning to perform move operation so we no need to process the payload. For this reason no need to create an XSD.



Step 3:
now open file adapter .jca file which looks as below.

=====================================================================
<adapter-config name="FileAdptMoveTest" adapter="File Adapter" wsdlLocation="FileAdptMoveTest.wsdl" xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata">
 
  <connection-factory location="eis/FileAdapter"/>
  <endpoint-interaction portType="FileMove_ptt" operation="FileMove">
    <interaction-spec className="oracle.tip.adapter.file.outbound.FileReadInteractionSpec">
      <property name="DeleteFile" value="true"/>
      <property name="PhysicalDirectory" value="C:/Dummy path"/>
      <property name="FileName" value="dummyFileName.txt"/>
    </interaction-spec>
  </endpoint-interaction>
</adapter-config> =====================================================================

Step 4:

Now replace <endpoint-interaction>-----</endpoint-interaction> with below code.
<interaction-spec className="oracle.tip.adapter.file.outbound.FileIoInteractionSpec">
      <property name="SourcePhysicalDirectory" value="foo1"/>
      <property name="SourceFileName" value="bar1"/>
      <property name="TargetPhysicalDirectory" value="foo2"/>
      <property name="TargetFileName" value="bar2"/>
      <property name="Type" value="MOVE"/>
</interaction-spec>

After the change in .jca file, it should looks as below.
=================================================================
<adapter-config name="FileAdptMoveTest" adapter="File Adapter"
                wsdlLocation="FileAdptMoveTest.wsdl"
                xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata">
    <connection-factory location="eis/FileAdapter"/>
    <endpoint-interaction portType="FileMove_ptt" operation="FileMove">
        <interaction-spec className="oracle.tip.adapter.file.outbound.FileIoInteractionSpec">
            <property name="SourcePhysicalDirectory" value="C:\Users\Fusion\Desktop\source"/>
            <property name="SourceFileName" value="student.txt"/>
            <property name="TargetPhysicalDirectory" value="C:\Users\Fusion\Desktop\target"/>
            <property name="TargetFileName" value="studentNew.txt"/>
            <property name="Type" value="MOVE"/>
        </interaction-spec>
    </endpoint-interaction>
</adapter-config>
=================================================================
Note : Note: You have modified the className attribute, and added SourcePhysicalDirectory, SourceFileName,TargetPhysicalDirectory, TargetFileName and Type.  The Type attributes decides the type of operation. Apart from MOVE, the other acceptable values for the Type attribute are COPY and DELETE.

Note :  SourceFileName and TargetFileName no need to be same. we can provide different file names.

Note : Currently, the values for the source and target details are dummy. You must populate them at run-time with .The source and target details are hardcoded in the preceding example. You can also provide these details as run-time parameters.

       (a) create 4 string variables in BPEL.
                   <variable name="sourceDirectory" type="xsd:string"/>
                   <variable name="sourceFileName" type="xsd:string"/>
                   <variable name="targetDirectory" type="xsd:string"/>
                   <variable name="targetFileName" type="xsd:string"/>
            Note: Make sure about namespace in .bpel file. Just cross check below namespace is available  in .bpel or not.
                      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      (b) get the source and target folder path , source and target file name from any source. Like recieve activity input variable or from a DVM or from a table. Some how get the required date and by using Assign activity copy the data from proper source to newly created variables.


Step 5:
Now open .bpel source view.
Add custom properties in invoke activity.

Existing code:
 <invoke name="Invoke1" inputVariable="Invoke1_FileMove_InputVariable"
                outputVariable="Invoke1_FileMove_OutputVariable"
                partnerLink="FileAdptMoveTest" portType="ns1:FileMove_ptt"
                operation="FileMove" bpelx:invokeAsDetail="no"/>

Modified Code:
 <invoke name="Invoke1" inputVariable="Invoke1_FileMove_InputVariable"
                outputVariable="Invoke1_FileMove_OutputVariable"
                partnerLink="FileAdptMoveTest" portType="ns1:FileMove_ptt"
                operation="FileMove" bpelx:invokeAsDetail="no">
<bpelx:inputProperty name="jca.file.SourceDirectory" variable="sourceDirectory"/>
<bpelx:inputProperty name="jca.file.SourceFileName" variable="sourceFileName"/>
<bpelx:inputProperty name="jca.file.TargetDirectory" variable="targetDirectory"/>
<bpelx:inputProperty name="jca.file.TargetFileName" variable="targetFileName"/>
</invoke>

sourceDirectory, sourceFileName, targetDirectory and targetFileName are string variables which we created in Step4.

NOTE : above properties syntax is related to bpel 1.1 version.




Friday 24 October 2014

Part 1 : Oracle service cloud(Rightnow) & Oracle SOA integration

 Oracle SOA suite 11g integration with Oracle service cloud (Rightnow CX)
Part-1


Generate Key Store :

Step 1 :
open cmd prompt in admin mode (right click and run as administrator.)



Step 2 :
in my machine "keytool" is available in
"C:\Program Files\Java\jdk1.7.0_60\bin"

Step 3:
In CMD prompt enter into above path as shown in below image.

Step 4 (optional if you want to use default key store : DemoTrust.jks):
generate new keystore with below cmd.
keytool -genkeypair -keyalg RSA -alias orakey -keypass welcome1 -keystore <wl_home>\server\lib\SOAKeystore.jks -storepass welcome1 -validity 3600

Answer the questions as per your environment.
What is your first and last name?
  [Unknown]:  kumar korada
What is the name of your organizational unit?
  [Unknown]:  it
What is the name of your organization?
  [Unknown]:  it
What is the name of your City or Locality?
  [Unknown]:  abcd
What is the name of your State or Province?
  [Unknown]:  ab
What is the two-letter country code for this unit?
  [Unknown]:  in
Is CN=kumar korada, OU=it, O=it, L=abcd, ST=ab, C=in correct?
  [no]:  yes
NOTE: 
1) Observe "SOAKeystore.jk" created in "<wl_home>\server\lib\" folder.
2) "-keypass welcome1" will be used as keystore password.
3) .jks file name and password are user defined.
4) when ever we want to import any certificate into .jks file we should supply .jks file password. So it is mandatory to remember password. (not down some where :) )

NOTE:
As i mentioned earlier creation of keystore (.jks file)  is optional. We can use default .jks file which comes with WL server installation.

Default jks file name : DemoTrust.jks
Default jks password : DemoTrustKeyStorePassPharse

NOTE: DemoTrust.jks and DemoTrustKeyStorePassPharse are case sensitive.

Step 5 :
Get Oracle Service Cloud (RNCX) certificate with the help of RNCX wsdl.

WSDL syntax :
https://<host_name>/cgi-bin/<interface>.cfg/services/soap?wsdl

start internet explorer as admin


paste the wsdl in address bar. Now we can see gold colored lock icon.

 
 Click on lock icon and click View Certificate.
 
In the popup --> select  Details tab --> Public Key --> copy to file (save the certificate in a file)
 
 
 
 

Step 6 :
import rightnow certificate into keystore.

copy .cer file into <WL_HOME>/server/lib

Run below script in cmd prompt, to import Rightnow public key certificate into weblogic key store (.jks file)

keytool -importcert -alias rightnowcx -file <WL_HOME>\server\lib\rightnowcx.cer -keystore <WL_HOME>\server\lib\SOAKeystore.jks -storepass welcome1

cretificate imported into key store.

Step 7 :
Log in into "EM"
http://<host name>:<weblogic port>/em

expand Weblogic Domain --> right click on domain name --> Security --> Security Provider Configuration



click on Configure button.




password : provide keystore password (as per above script password is "welcome1").
key Alias & Crypt Alias : rightnow (as per above script ).