Showing posts with label BPEL Process. Show all posts
Showing posts with label BPEL Process. Show all posts

Thursday, June 17, 2010

Disabling WS Addressing in BPEL

Background and Problem
In BPEL, the WS Addressing seems to be enabled by default. The external Web Service that is invoked from BPEL Service receives the WS Addressing and first verifies the end point. For some reason this end point that was generated by BPEL is incorrect and so throws an error. The only way the communication can be successful is to disable the WS Addressing.

Solution
In SOA 11.1.1.3, this can be achieved by adding a binding property in the BPEL.

  • Select the WebService and you will see the Property Inspector.
  • Add the Property "oracle.soa.ws.outbound.omitWSA" and set it to true. As of this version this property is not available in the dropdown. So you need to add this.
  • Save it and deploy the new Service to test it out.
  • The Steps are shown below as an image

Friday, March 26, 2010

Oracle BPEL 11g Best Practices

  1. BPEL has to be primarily used for orchestrating the services. 
    • Do not add complex business logic here. It should belong to the service layer.
  2. Create scopes for each step of the flow in the process so as to make it modular.  This will help in creating local variables within that scope. Use Global variables when required(just like your java or C++ programming style). This will help in maintainability. Note : Adding too many scopes may affect the performance. In that case you may want top consider creating sequences.
  3. Adopt naming standards and comply to it. This should be part of the governance strategy. This looks trivial but is important if you want someone else to understand the code and make changes.
  4. It is good practice to have a Mediator in the Composite. Try to get most of the transformations done by the Mediator.
  5. Have all the business rules implemented by the Oracle Business Rules
  6. Handle all the exceptions
  7. Adopt test driven development. Create test cases with a tool like SoapUI for each process and make this part of your governance strategy.
  8. Instead of BPEL, you should consider implementing the process in BPM. This has the advantage of modeling it in BPMN so that it can be easily understood by the Business and also helps the model and implementation to be synchronized at all times. If you haven't considered it so far then it is time you take a look at 
  9. The flow of the BPEL process should be very intuitive.
    • The reason enterprises are investing heavily in this to be agile to change. So, to make this happen , make the steps in the flow linear as much as possible so that a new step can be added/reordered easily by just drag and drop. I have seen very complex nested creation of the following flow which after refactoring looks as below.

Saturday, January 30, 2010

Using Java Embedding Task

Peter Ebell has written an excellent article "Embedding Java in BPEL process" which explains the inner details of how BPEL engine invokes the java classes.

Another article "How to deploy Java classes with BPEL process" goes through the deployment process.

The System.out.println output can be found in the console.

Here is a sample code that outputs the request of type Element to an XML String.

Note : Debugging the problem is a time consuming activity.

try{

System.out.println("IN JAVA EMBEDDING*******************:");
org.w3c.dom.Element inputElement = (org.w3c.dom.Element)getVariableData("inputVariable","payload","/client:process");
System.out.println("*******************GOT THE ELEMENT:*******************");
String inputElementXML = com.collaxa.cube.xml.dom.DOMUtil.toXML(inputElement);
System.out.println("inputElementXML :" + inputElementXML);
setVariableData("outputVariable", "payload",
"/client:processResponse/client:result", inputElementXML);
}catch(Exception e){
System.out.println("Exception in Embedded Java:" + e.toString());
}

Friday, January 29, 2010

Processing request or response as String but with XML structure in BPEL

When the process has been designed(bad design as it is not bound to schema) to accept the request as a String which is in XML format, then development becomes difficult. Oracle BPEL has been developed to deal with request and responses that are bound to schemas and so offer rich XML data manipulation.

Let us see what needs to be done when the request is receved as a Strng in XML format. The string needs to be mapped to an XML element to simplify the processing of payload
  • Use oraext:parseEscapedXML() to read the XML to an Element. If you encounter any problem in this please check the namespace as suggested here.
If the request to another webservice needs to be in a String format(again bad design) then let us see the available options
  • getContentAsString() converts the XML to string but escapes the '<' but leaves the '>' intact.
  • oraext:get-content-as-string() converts to XML but escapes both '<' and '>'. In em console, view the raw xml. If you view in the HTML it looks fine. 
  • Use Java Embedding(this is covered in a separate blog)

Thursday, January 14, 2010

SOA BPEL 11g examples

Some BPEL examples based on SOA Suite 11g developed by the SOA/BPM development team are available here. Download the zip, extract the files and open the example in JDeveloper11g. Deploy and test them.

 
Note: The documentaton is minimal but the examples can be understood by going through the code and running them.

Wednesday, January 6, 2010

Performance Tuning of Oracle BPEL

Following are the list of articles that are worth going through to improve the performance of BPEL
The primary areas to look for performance tuning are below. Sometimes, it is a tradeoff between performance, reliability and security and the decision has to be made after carefully weighing the pros and cons.
  1. Oracle Weblogic JVM Memory
  2. Dehydration Store Database Performance Tuning
  3. Should the process be stored in the dehydration store? By default the value is set to true so that there is no dehydration done. Set the idempotent flag to false if you need the process instance to be dehydrated.
  4. DB Connection Pooling
  5. InvokerBean thread value. By default it is 1 thread per process. But, if there are multiple branches/flows in the process this could be increased so that the processing is faster. Check the 'Dispatcher Invoke Threads' and 'Dispatcher Engine Threads' values.
  6. Logging
  7. Set Audit Level to 'Production'. Payload is not stored.
  8. Feasibility for the usage of REST service as it is lightweight.
  9. Security : Overhead increases as the level of security gets higher. The overhead directly affects the performance.

Saturday, September 19, 2009

Creation of a Synchronous BPEL Process

This will cover the concepts, design, testing and deployment of Synchronous BPEL Process.

What this blog helps to understand
  • Using WebService PartnerLink
  • Using Invoke BPEL Activtiy
  • Using the webservice.
  • How to create a Synchronized BPEL Process
Note:
  • We will utilize the webservice that was created earlier. This will help in understanding how the webservice that you created before is being orchestrated by the BPEL Process.
  • We shall not do the data transformation between different data types. Fortunately, int to string and string to double conversion seems to be done out of the box.
 Intent
  1. To create a Synchronous BPEL Process that takes a FICO score(input) and determines the APR(output). Let us call this a MortgageProcess.   
Prerequisite
Concepts of Synchronous Service
  • This article explains the Synchronous and Asynchronous webservices
  • The difference between Synchronous and Asynchronous BPEL Process is excellently defined here and I shall not duplicate this below.
Design
  • Choose "New Project ..."
  • In the "New Gallery" window, select "SOA Project"
  • In the "Create SOA Project Step1 of 2", enter Project Name as "SynchronousMortgage"
  • In the "Create SOA Project Step2 of 2", select the Composite Template "Composite with BPEL" and click on "Finish" button.
  • This will launch the "Create BPEL Process" window as seen below


  • After creation, the default design view of the MortgageProcess looks like below


  • Now, invoke the CreditService webservice. You can do this by dragging and dropping the "Partner Link (WebService/Adapter)" from the "BPEL Sevices" section in the Resource Palette(as shown below) to the Partner Links swim lane on the right side. 


  • Once it is dropped, the "Create Partner Link" dialog appears where the partner link needs to be configured to invoke the CreditService.



  • Now, there should be a BPEL Activity to invoke the WebService through the Partner Link we configured in the previous step. For that, drag the "Invoke" BPEL Activity from Component Palette>BPEL Activities and Components and drop it into the middle lane and configure it as shown below.


  • Connect the InvokeActivity with the "SyncCreditProcess" PartnerLink  and configure it as shown below.




  • Now, assign the "Invoke_CreditProcess_process_InputVariable" with the input received from the client which is the FICO score. When the process runs, the web service operation is invoked and this input value is passed to it.


 


  • Double click on the Assign Activity

  • In "General" tab, change the name to a meaningful one like "Assign_FICO"
  • Go to "Copy Operation" tab
  • Click on green + arrow to select the "Copy Operation..."

  • In the "Create Copy Operation" screen do the following




  • When the process runs, the web service operation returns the response instantaneously(synchronized). Since this value has to be returned to the client, assign "Invoke_CreditProcess_process_OutputVariable" to the response (output which is the APR)

  • Drag and drop the Assign Activity in between Receive and Reply activities as seen below


  •  Double click on the Assign Activity
  • In "General" tab, change the name to a meaningful one like "Assign_APR"
  • Go to "Copy Operation" tab
  • Click on green + arrow to select the "Copy Operation..."
  • In the "Create Copy Operation" screen do the following


 Deployment
  1. Now save the .bpel file
  2. Make the project
  3. See the compiler log. You will see warning messages on assigning incompatible types. This is true since the FICO score should be integer and APR is returned as double. Since we wanted to focus only on the creation of synchronous process we shall ignore such wrong programming practice for this example.
  4. Deploy to Crystal Domain
  5. Check the Deployment log to see if the dployment is successull.
Testing
  • Go to Oracle Enterprise Manager 
  • Under SOA>soa infro, you can see SynchronousMortgage deployed.
  • On the right side, clck on Test button
  • Enter the InputValue 500 and the system outputs 20.
Note
  •  Note that it is the type of response(immediate or callback) that decides if the BPEL Process is Synchronous or Asynchronous.
  • Each domain has the attribute syncMaxWaitTime that by default is set to 60 seconds and can be reconfigured by the doman administrator. The Invoke Activity cannot wait for more than this time and will time out.
Real World Scenarios
  • A Credit Card Authorization during an online purchase is good case for a Synchronous Process as an authorizaton response is expected by the CardHolder immediately. 

Friday, September 4, 2009

Creation of a Simple BPEL Process - Hello

We shall create a very simple BPEL process. The intent is to learn the following
  1. Overview of this exercise
  2. BPEL Designer in JDeveloper
  3. Partner Link
  4. Process Activities - Receive, Invoke, Assign
  5. Data Transformation
  6. Compilation
  7. Deployment
  8. Accessing Enterprise Manager
  9. Creation of Test Suite
Overview
We will create a very simple BPEL process. The process does not orchestrate any services. It just takes an input from the client and transforms it and sends it back as a response.
Example
Input = "Hello"
Output = "Hello CrystalTrain"

Creation of BPEL Process
This involves the following steps
  1. Creation of Application
  2. Creation of Project
  3. Data Transformation
  4. Compilation, Deployment and Testing 
This prompts you to create a BPEL Process

The default process comprises of the following
Below is the design view of the process
Let us take a look at the Receive BPEL Activity. It receives the request from the client and holds the payload of the request in the inputVariable.
Let us take a look at the Reply BPEL Activity. It sends a response back to the client with the data stored in outputVariable.
Our intent is to modify the message received from the client. This is stored in inputVariable.
This can be done in Assign BPEL Activity as can be seen below.
Drag the Assign BPEL Activity that is avalable in the ComponentPalette>BPEL Activities and Components
Drag and Drop the Assign BPEL Activity in the highlighted circle in between Receive and Reply Activities
Now edit the Assign Operation.
In General Tab, Rename it to "TransformMessage"
In Copy tab, 
You will see "Create Insert-After Operation" window
In the left hand side pane, select "Expression" as the Type
Now using "XPath Expression Builder", modify the inputVariable as seen below.
Assign the transformed value to the outputVariable
Build and Deploy
Save the project.
Right click on the project and make "HelloWorld.jpr". This will compile the project and output any errors to the log window.
Now right click on the project and select Deploy>HelloWorld>to Crystal
Note : Your ApplicationServer connection in the IDE should be up.
Accept the default values in "SOA Deployment Configuration Dialog".
Enter the domain credentials when asked.
Check the Deployment log to see that the status of the deployment.
Testing the BPEL Process
Go to EnterpriseManager at http://localhost:7001/
After entering your credentials you will be taken to the Home page (The login takes a looooong time)
To the left side, you will see
Click on the "Test" button
Enter the Input now

The response looks as follows


As show above, click on "Launch Message Flow Trace" to see the Audt Trail, Flow, XML from the request till the response.

Click on "Simple Process" to view the Flow Trace.

See below for the Audit Trail of this instance of the process.


Select the "Flow" tab to see the flow of request throgh the process actvities

Now, since you have successfully created your first BPEL process, start playing with the BPEL Designer and the EnterpriseManager. Make as many mistakes as possible and try to figure out the resolution for each. Be BOLD and try out the following. The more mistakes you make now the less you will make in future. 
  1. In the BPEL Designer in JDeveloper, view the Source of the .bpel file and see if you can make any sense of it.
  2. Remve the expression from the Assign activity and try to build the project. See the compilation errors.
  3. Open the logs at C:\oraclesoa\user_projects\domains\crystal_domain\servers\soa_server1\logs to familiarise yourselves.
  4. Go to the Design mode and edit the Assign process activity and change the expression value. Save the changes and deploy it. Follow the steps shown in the figure below.