Wednesday, May 22, 2013

Setting and Getting Preferences SOA Suite 11G

Deployment descriptors are BPEL process service component properties used at runtime by Oracle WebLogic Server, Oracle Enterprise Manager, or both.

Oracle has provided the functionality to add preferences to your bpel process.Preferences are like a variable whose value can be changed from EM console requiring no code change.For instance,consider one use case for File adapter.Suppose in test environment we are writing the files to /test/source location.Now once the code is migrated to production environment, now you want to write the files to /prod/source location.

These type of properties can be set using preferences, where you have to just update the value of preference variable for dircetory location on EM and there you go.We dont have to explicitly make changes in the code to point it to new location and deploy it again.

Depends upon requirement,what type of variables in BPEL can be declared as preferences.Ill be demonstrating how to set and get the values of these preference variables and how to change them using Enterprise Manager.


Step1: I will be using "HelloWorld" tutorial for this that we created in my first post.Open up your Hello World BPEL process.
Step2: Got to source of composite.xml and add "<property name="bpel.preference.MyVar">Old Value in Response</property>" in component section.Here we are setting the value for variable "MyVar" which we will be using in our BPEL process.
Step3: Now double click and open your BPEL process.Open the assign action.We will be populating the result of our BPEL process using this preference variable.Double click on result of our output variable to open up the expression window.Drill down to BPEL XPath Extension Functions and insert getPreference into expression field.Add the preference var in the function as ora:getPreference("MyVar").Make sure you enclose your preference variable using double quotes.Click OK.
Step4: your assign action will look like this.Click OK.
Step5: Now deploy your composite on EM and test it passing any random input and open the flow trace of invoke composite.In the assign action you will see value of result as "Old Value in Response".It is the same value that we set inside composite.xml.
Step6: Now we will change this value from EM to some other value.Right click on SOA-Infra --> Administration --> System MBean Browser.
Step7: Drill down to your composie following this path oracle.soa.config-->Mgd Sever --> SCAComposite-->HeloWorld-->SCacomponnt.SCAComposite-->HelloWorldProcess.
Step8: Click on the properties tab on the right hand side and expand properties tab to find out element containg your defined preference variable
Step9: Change its value and click "Apply"
Step10: Test your interface again and thsi time you will see the updated value in the result.
In this way you can define n number of preference variables in your composite.xml and use them in your BPEL process.Should you guys have any question ,feel free to ask.

Happy Learning,
Cheers









Tuesday, May 14, 2013

Developing and Deploying Custom XPath/XSL Functions

Apart from XPATH functions provided by Oracle,there are sometimes requirement that normal function cannot fulfil.To support this oracle has provided the privilege to create Custom XPATH functions,which can be used along with normal XPATH/XSL functions in your XSLs or Assign actions.

Consider one usecase where you have to remove all the special characters and spaces from a given input and return the trimmed output.For implementing this we will create one custom XSL function and use it in our project.




Step1: Create a java class and write down your function logic in that class.Compile and test it.

Sample Java Code:

package com;

public class RemoveSpecialCharacters {
    public static String removeChars(String input, String regex, String replaceemntString)
    {
      String result = input.replaceAll(regex, replaceemntString);
      return result;
    }

    public static void main(String[] args) {
        RemoveSpecialCharacters removeSpecialCharacters = new RemoveSpecialCharacters();
        String input = "((80)-IN855A.0+11)";
            System.out.println(removeChars(input, "[^A-Za-z^0-9]", ""));
    }
}

 

Step2: Custom functions should be registered in JDeveloper to be able to show them with BPEL expression builder and in the XSL Mapper. To do that, provide a User Defined Extension Functions config file [ext-soa-xpath-functions-config.xml], as shown belwo, and register it with JDeveloper through FilePreferencesXSL Map.Modify this xml file to incoorporate your changes.
Sample XML:

<?xml version="1.0" encoding="UTF-8"?>
<soa-xpath-functions version="11.1.1"
   xmlns="http://xmlns.oracle.com/soa/config/xpath"
   xmlns:trimSC="http://www.oracle.com/XSL/Transform/java/com.RemoveSpecialCharacters"
   >
    <function name="trimSC:removeChars">
    <className>com.RemoveSpecialCharacters</className>
    <return type="string"/>
    <params>
       <param name = "input" type="string"/>
       <param name = "regex" type="string"/>
       <param name = "replaceemntString" type="string"/>
   </params>
    <desc/>
     <detail>
       <![CDATA[This function returns the value after removing all the special
       characters from the input except alphabets and integerse.]]>
    </detail>
   </function>
 
</soa-xpath-functions>

Step3: Now we will create one jar file    for out function.Create a new folder and paste your class file with complete folder structure in it,In the same folder create one new folder named as "META-INF" and place your ext-soa-xpath-functions-config.xml in it.
Step4: Create jar file using "jar -cvf functionname.jar *.*" command.
Step5: Now custom function jar created in last step will be registered with JDev.Go to Tools --> Preferences.
Step6: Drill down to SOA tab and add your jar file using ADD Button.
Step7: Save and restart your JDev.Cross Check and verify your function under user defined functions.
Step8: We will test our new function now.I will be creating one dummy xsl using schema i used in DVM Tutorial published in my previous posts.Give the input,regular expression and replacement string.
Step9: Test your xsl file, you would be able to see the trimmed output in the target xml. 
In this way,you can create any custom XSLT functions depeding upon the requirement and use it in your project.
NOTE: To make this function available at SOA runtime place the jar file under $SOA_HOME/user_projects/domains/domain_name/lib.


Take restart of your server and test newly created function.



Happy Learning,
Cheers
 

Monday, May 13, 2013

Passing Dynamic values to JCA Adapters for Files in SOA 11G

Hi All,

Sometimes,there are requirements like this when you have to pass values such as file names or file directory at runtime while working with File adapters.For all the outbound operations such as write,sync Read and list files you can dynamically pass filenames and directories to your JCA adapter during invocation of a BPEL process.

To illustrate the above usecase,Ill be modifying my existing code which I developed for explaining DVMs in my last post.



Step1: Drag and drop a file adapter onto the external references lane.
Step2: File adapter wizard will open up.Configure the file adapter for write operation and specifiy output directory and file name to be written.Please note these values are dummy values since,they will be modified at runtime when call to file adapter will be made.
Step3: Same schema used for DVM tutorial will be used here for defining the messages for the write file operation.Click finish.

Step4: Call to File adapter is made using invoke activity and input variable for file adapter is created using "+" sign.To see how to create variables for invoke activities kindly refer my previous posts.
Step5: Now drag and drop assign activity for populating the input payload for file adapter.Fields such as FName,LName,City,Designation in the input payload is mapped to the input variable for invoking file adapter.Create two new variables of string data type namely "NewFileName" and "NewDir".Now we will set the values for these two variables in the same assign activityiin which we mapped the inpt file variable.These are the values that will be passed at runtime to file adapter for write operation.


Step6: Now, we will set the new filename and new filedirectory.Double click the invoke activity and switch to "Properties" tab.Drill down to properties "jca.file.filename" and set its values to variable that we created "NewFileName".
Step7: In the same manner for "jca.file.Directory" set its values to "NewDir".
Step8: In this manner we pass the values to any JCA adapter during runtime.
Step9: Save all compile and deploy hte code to EM.
Step10: Test the newly created SOA service.Pass the values and invoke Test Web Service.
Step11: Open up the flow trace of the invoked instance and notice the value for filename and filedir being passed at runtime.
Step12: Now got to the location whose dir path was given in file adapter at runtime.File is written with a name we gave at runtime.
Step13: Open the file to verify the contents of the file.





Step14: Likewise,you guys can pass dynamic values to other JCA adapters as well.List of available properties for every adapter can be seen under properties tab of an invoke activity.Hope you guys enjoyed and learned the concept of passing dynamic values at runtime.


Happy Learning,
Cheers.
















Tuesday, May 7, 2013

Working with DVM in SOA Suite 11G

Hi Folks,

Today, we are going to learn the concept of Domain Value Maps(DVM) in Oracle SOA Suite 11G. They enable you to map from one vocabulary used in a given domain to another vocabulary used in a different domain. For example, one domain may represent a city with a long name (Mumbai), while another domain may represent a city with a short name (MB). In such cases, you can directly map the values by using domain value maps.

Domain value map values are static. You specify the domain value map values at design time using Oracle JDeveloper, and then at runtime, the domain value map columns are looked up for values.

Use of DVM will be demonstrated in forecoming steps.Prior to that letme give you brief overview of our usecase.We will create a synchronous BPEL process that will receive inputs such as firstname,lastname,city and will retrurn corresponding city code in the output, along with full name.


Step1: First create a new SOA project "DVMTutorial" and create a new synchronous BPEL process named as "DVMProcess" based on WSDL

 Step2: Now lets create DVM.Go to NEW--> SOA Tier --> Domain Value Map and click OK. 
Step3: Wizard will open to create DVM.Give the name to dvm as "Cities.dvm" and under Domain Names add 2 fields "CityName" and "CityCode" with values as "Mumbai" and "MB" respectively.Click OK.
Step4: Cities.dvm will get created.Kindly note the extension of dvm files are ".dvm". Now add some more data to this DVM and save all.
Step5: Open your BPEL process.We will be manipulating the cityname in the input and will return corresponding CityCode in the output.For this, drag and drop assign activity between receive and reply activity.Drill down to City in your output variable and add expression.
Step6:  Scroll through list of avilable function and under "DVM Functions" ,insert lookupValue onto the expression field.If you see in the description of the function: 

dvm:lookupValue(dvmMetadataURI as string, SourceColumnName as string,SourceValue as string, TargetColumnName as string, DefaultValue as string) as string. 

It expects dvm to be used,source column name and source column value to be looked for in dvm and target column name whose corresponding value will be derived from DVM.
Step7: Insert values for source column as "CityName" and its value will be passed runtime during invocation of BPEL process,target column "CityCode" whose value will be looked upon at runtime.Your expression will look something like this: 

dvm:lookupValue("Cities.dvm","CityName",bpws:getVariableData('inputVariable','payload','/ns1:EmployeeDetails/ns1:emptype/ns1:City'),"CityCode","")

Step8:  Click OK,save all and deploy your composite to EM.

Testing your Composite:

Step1: Open up your composite from EM and click on Test Button.Pass values in all fields and under City field enetr "Mumbai" and test.You will see in the response document City value "MB".

Step2: Similarly test one more scenario passing "NewYork" in the City field and this time "NY" will come in response.

In this way we can use DVM in our projects for mapping dictionary from ome domain to another domain.Hope this post was useful for you guys.

Happy Learning,
Cheers.....

Thursday, May 2, 2013

Renaimg BPEL process in Oracle SOA 11G

Recently there was a requirement in my project, where I had to change the name of BPEL process in our SOA Composite.Since I  have used rename functionality in OSB numerous times.Likewise,in BPEL,I thought it would be also a piece of cake as its just a simple Rename.Unfortunately, it was not that easy and infact it was a bit pain,because Oracle didn't provide much functioanlity to implement this in JDev.One option I used was "Refractor", but it just renamed the BPEL process,as it was supposed to rename BPEL in all its dependencies as well.

After doing some googling, I did find how to rename a BPEL process but the information that I got was not precise and infact was in bit and pieces.Finally, I was able to rename the BPEL process after doing changes in couple of files.Since very less information is available on net regarding this,I tought of sharing my experience and steps I followed to rename a particular BPEL process.Steps that are mentioned here have been implemented in 11G.

Following files need to be changed for renaming a BPEL process:

  • composite.xml
  • .bpel
  • .componenttype (of your BPEL process)
Step1: I will be using my "JMSLab" project for this usecase,which I have created in my tutorial for JMS Adapter.Open up the project and drill down to our BPEl process. "BPELProcess" in our case. I will be renaming this BPEL process to new name as "RenamedBPELProcess".
Step2: Click on your .bpel file and go to Menu --> Refaractor Tab --> Rename.
Step3: Rename file window will open up.Change the name of BPEL process to new name you require ,"RenamedBPELProcess" in our process.
Step4: Now we need to make changes in .bpel file.Double click the "RenamedBPELProces.bpel" under Application Navigator on the left side and go to Source.Three places will be changed as shown in the screenshot: process name,target namespace and prefix namespace.
Step5: After replacing all three occurences your BPEL file will look like this.Also new componenttype file will be created for your renamed BPEL process.
Step6: Now go to the source of composite.xml and under component tag change the BPEL process name.Also, make changes in all the wire tags where BPEL proces is occuring.
Step7: Final step is to copy all the contents to RenamedBPELProcess.componenttype from BPELProcess.componenttype(old file) and after copying delete the old componenttype file for BPEL process.
Step8: Save all.
Step9:  Now verify your changes by building the jpr file.

In this way you can rename any BPEL Process.Though it is very tedious,but worthful as there is no other alternative provided by Oracle.
Hope you Guys liked it.Stay tuned in for my next blog.


HappyLearning,
Cheers,