Saturday, December 20, 2014

Helloworld in OSB

'Helloworld' example is very confusing in OSB specially for SOA developers, so lets do it.

For creating this Helloworld web service in OSB we will need XSD and concrete WSDL, we can can get these from JDeveloper.

Step 1.) From JDeveloper I created a simple schema file as below


Step 2.) In JDeveloper create a synchronous BPEL process with input and output using this schema file, deploy this BPEL to server and get the concrete WSDL file from server.






Download this wsdl file, and we are ready to start the development in OSB.

Now lets go to Eclipse OSB IDE.

Step 3.) Create OSB configuration project as shown below



Now create a new OSB project





Now create different folders as below and copy the schema and WSDL files in the respective folders, also remember to change the xsd file location in wsdl file.



Step 4.) To create a Helloworld in BPEL we would have a exposed web service adapter and a BPEL process, however there is no adapter on external reference, so in OSB we wont have any business service, See the screen shot below, this is the first confusion of any SOA developer, better understand this here.




Step 5.) Create a proxy service 'Helloworld_PS' and use the concrete WSDL which we have downloaded from SOA server.




Select WSDL and web service, browse for wsdl file and select port and press OK.




Select Yes for transport configuration changes.


This gives us a synchronous OSB web service, more like a sync BPEL process without any activity.

Step 6.) Now all we have to do is use a assign activity which will concat Hello !! with our input and pass us as output, so simple isn't it ? this is the next confusion and quit a confusion honestly.

Click on flow tab and go to the flow.



From the design pallet > Oracle Service Bus design flow > Nodes > Pipeline Pair drag and drop it after Helloworld_PS.

Pipeline pair separates the input and output flow and makes it easier to customize transformations and other operations on either the request or response side of the node. Right now we only have a entry node and if we test it, it will echo with the input.

In progess

Friday, December 19, 2014

Introduction to OSB

This is my first post on OSB, being a SOA developer OSB is always confusing, I will try to present OSB from the eyes of a Oracle SOA Developer.

OSB is stateless.

1. This means their is no SOA_INFRA schema where all the activities are getting logged, being a SOA developer we know whats the importance of audit trail when we have to debug.

2. We don't have asynchronous process in OSB, for the obvious reason as there is no place where we can dehydrate an instance and invoke it back when we receive the response.

OSB Vs SOA

1. As their is no logging in the DB (SOA_INFRA), which makes it very fast, according to claims its 2.5 times faster in performance then SOA. I say everything happens in air in OSB.

2. OSB is a perfect technology where performance is mainly important.

OSB Vs Mediator

From my experience I have found mediator is nowhere faster then BPEL which is theoretically told, so it does not stand anywhere near to OSB.

Mediator can only connect different web services or adapter, however we can not put any orchestration logic.

So OSB is BPEL plus Mediator and is 2.5 times faster but has no audit trail.

Basic components of OSB

There are only two components in OSB which do all the magic, Business Service and Proxy Service

Business Service:

Business Service is adapter of SOA.
We have separate adapters for web service, database, JMS, file/ftp, rest etc, in OSB business service acts as single adapter to do absolutely everything and can do actually more then SOA adapters.

Proxy Service:

Proxy service is BPEL activity of SOA.
All the orchestration logic is written inside proxy service.







Wednesday, December 17, 2014

How to migrate SOA process from 10G to 11G


I have been doing lot of migration from SOA 10G to 11G from past few months and would like to share how I do it, bit late, however better late then never.

Migration is overall a straight forward and tool based task.

I will take an example of 3 simple SOA 10G process and migrate them to SOA 11G using JDeveloper.
I have BPELProcessA and BPELProcessB which are being invoked from BPELProcessC.


Step 1.) First check the BPEL process which are independent, i.e. they are not invoking any other BPEL process, these independent process are the first one to be migrated and deployed to SOA 11G server, in our case BPELProcessA and BPELProcessA.


Step 2.) If your BPEL process was renamed at any point of time, then it might create issues later while you are doing some enhancement in the SOA 11G composite, the quickest way to check if this was renamed is to go to bpel.xml file and check , in the below print screen we can see the id and src are two different name, so change BPELProcessA back to original name ProcessA


*** I have not used renamed BPEL process for this, so I will continue with my same process names.

Step 3.) Now we can migrate BPELProcessA and BPELProcessB using JDeveloper, we simply open the SOA 10G process in 11G JDeveloper, as soon as we click on .jpr file the migration wizard pops up.









Step 4.) We can put the .xsd and .xsl files to proper xsd and xsl folder and make necessary changes in WSDL and .bpel file respectively, unnecessary output folder can be deleted as we have deploy folder instead.


Step 5.) Deploy this BPELProcessA composite to Weblogic server and repeat the same steps for BPELProcessB as well.

Step 6.) Now we have to migrate the dependent process BPELProcessC, if we see the bpel.xml file of this process we can see the WSDL URL's for BPELProcessA and BPELProcessB, we have to replace these 10G URL's with the new URL's (SOA 11G), once this is done repeat step 1-5








This completes the migration.

Post migration changes

1.) Change the location of .xsd and .xsl files to their respective folders

2.) If you were using preference in SOA 10G then in 11G it will be inside composite.xml file, you need to append bpel in the property name.

3.) Go to all the adapter and run the wizard to check if they are fine, if you find issues with the adapters better recreate it.

4.) In DB adapter we have requirements where we do logical delete in polling, however we want to update some other table or procedure from where we have polled from, below blog shows how this is done, if you have done this anywhere in your SOA 10G BPEL, its better to recreate the DB adapter fresh, as this has performance issues after migration.

http://shrikworld.blogspot.in/2011/05/customizing-delete-polling-strategy.html

5.) If you have used java activity inside your 10G BPEL we usually use inport which refer to packages in SOA 10G, the package names have changed in SOA 11G. So you might need to change the package names.










Tuesday, September 6, 2011

Fault handling in File adapter for CSV and XML files in SOA 11G

Hi All,

I will show how we can implement fault handling in file adapter when it is reading (polling) CSV files, I am using 11G and using its Fault Handling Framework.

This is a 2 step process,

1.) In the first step process we have a composite which is polling for CSV file's, if the file is bad then it's using fault-policies to do the required fault handling.

2.) The second step is creating a new composite which will exclusively catch the error details from the first process and log it (I have skipped the logging portion).

Step 1.) Create fault policies in composite which will poll for the .csv file.

This is how our composite looks.



This is the CSV file which I have used to configure the file adapter.

Employee.csv file
Name ID Age
yatan 101 29
yagya 102 27
yugansh 103 24

This is the XSD file which got created from the native format builder of file adapter.
Employee.xsd (Created from Jdev file adapter native format builder)



This is the contents inside the .jca file which shows the configuration details of this file adapter.



I have wired this File adapter with a BPEL process "ReadCSVBPEL". While creating this BPEL process I have given template as "Defile service later", inside the BPEL process I have used a receive activity to receive the data.



This is the Configuration inside the receive activity



The most important part is Fault Handling here, if the .csv file we are polling for is a bad file, i.e. empty file or not schema compliant then we should be notified about this.

The issue with file adapter is, if the file you are polling for is bad file it will simply rejected and the instance wont get created, this is not good as no one would ever know what happened to the files and where are they going.

I will show here fault-policies.xml and fault-bindings.xml
fault-bindings.xml



There are 2 places highlighted in red.

1.) name="rjm:ReadCSV", where is this coming from, This is the end point of the service, in the Oracle Developer Guide its little confusing as they have written here , the service end point is file adapter name here.


2.) This is actually the details of the composite which is exclusively doing the fault handling for file adapters. I will again describe this is detail.

Next file is fault-bindings.xml.

fault-bindings.xml


Now inside this file there are again 2 value highlighted in red, where is this value coming from,

1.) faultPolicy="RejectedMessages", this is value for our fault-policy id.
2.) ReadCSV, this is end point for the service.

Step 2.) We have design a new composite which will be used for catching the faults thrown by other composite which we have designed in Step 1.
The input for this service will be this type,
RejectedMessages.xsd



You can skip the below 5 steps by simply using this file.




1.) Create a new composite "FileFaultHandling" and put RejectedMessages.xsd after that drop a web service adapter to the exposed service area name it "RejectedMessageService" and on the WSDL URL use "Generate WSDL from Schema".



2.) Configure the WSDL file use the same namespace as used in RejectedMessages.xsd after that click on Add a new message part



3.) Use RejectedMessage as URL.



4.)


5.)



6.) Drop a new BPEL process with template as "Define service later", and wire the RejectedMessageService web service adapter with this BPEL process.



7.) Inside the BPEL process use a receive activity and configure it with the RejectedMessage service.

8.) Deploy the service and go to the EM to get its URL.

I told that I will describe in details about a URL in fault-policies.xml
inside fault-policies.xml.
This is the format
format - Absolute WSDL|service name|port name
WSDL of the FileFaultHandling service
Service name (This is the end point of this service)
portname (this is the port name of that service again)

Deploy 1st service and test.

I will keep "TestCSVFile2.csv" file at this location "C:\Files\CSVRead" and will simply write some junk data inside it, example aaaa, as this is not schema compliant it will get rejected and will call our FileFaultHandling service and will pass the data there.







Remember, this rejection message handler will not do complete fault handling, this is only going to reject empty files, files with some junk data or incorrect data on first line.

If we were reading a XML file then the file adapter will reject any file which is not schema compliant, the XML file will be thoroughly checked, however this is not in the case of CSV files where only empty/junk data files will be rejected, all the non schema compliant csv files will not be rejected by file adapter,so we have to do more work for fault handling when we are dealing with CSV files.

Monday, August 1, 2011

How to call a Java method inside a BPEL process using Java activity

Hi',
Inside a BPEL process we can call a Java class to use any of its methods. This helps in reusing the Java code from existing projects or sometimes doing things in Java which are still not possible in BPEL

This is a 2 step process

Create a .jar file of the Java project

1.) Below is the screen shot of the Java class which we want to use in our BPEL process.




2.) Create a JAR file of this Java project.

Right click on the Java project and select New


Now select the Deployment Profile under General and select JAR File under Items.



Give the Name to Jar file "HelloWorldJava"








Click on OK, and then right click on the project folder and deploy it.
This will create a .jar file of this java project.

This HelloWorld.Jar goes inside the deploy folder of this project by default.



Use java class from the .jar file inside the BPEL process

Create a new SOA composite and drop a BPEL process inside composite.xml , Copy the HelloWorldJava.jar which we just created in the presious steps inside the Composite "SCA-INF/lib" folder.


Now drop a Java Embedding activity inside the BPEL process.



Inside the Java Embedding use the below code



We need to do 2 things here first include the Jar in the project and then use import statement to use those classes inside the BPEL

1.) To include the JAR in the project, double click on the project to open the project properties click on "Libraries and class path" now click "Add JAR/Directory.." and include the jar file which we have placed inside the SCA-INF/lib folder of the same project.

2.) Use Import statement inside the BPEL source code, inside the BPEL process we have to manually use Import statement to import the java class in order to use the class inside the BPEL.



Create a new variable "Greeting" of String type, inside the Java code we are passing the output of the java method to this variable, this will bring the output of the java to BPEL process.



Use a Assign activity to map the Greeting variable to output variable.



Deploy and test.
Input



Output




Audit Flow






The Java activity is still not that advance to give developer error details, the exceptions thrown are very confusing, if the above steps are followed life can be little easy when Java activity is used.

Steps for using Java activity

1.) Creating JAR from JDEV
2.) Copy the JAR in the same projects SCA-INF/lib folder
3.) Include the JAR by going to "Libraries and class path".
4.) Use Import statement inside the source code of BPEL, make sure that all the import statement are included for what ever code is written inside the java acitvity, there is change in the package structure of various existing classes which are used inside 10G and 11G
example : For Java class Base64Decoder the import statement differ in 10G and 11G

10G "com.collaxa.common.util.Base64Encoder"
11G "oracle.soa.common.util.Base64Encoder"