Wednesday, December 16, 2009

Scheduling BPEL Service

If you would like to schedule a BPEL service every few hours then there is no direct support provided by the BPEL engine or Oracle Application Server to do this. This may be required when the service/process has to run as a batch process.

I have read about solutions using File Adapter, Database Adapter, process running in loop, etc.

The most elegant solution(in my view) is to develop a Java solution using Quartz Scheduler(open source) and deploy it as a war application in the Oracle Weblogc Server. You may want to externalize(from war) the jobs.xml so that the schedule time can be altered. You may also want to externalize the end points so that they can be modified as suited.

WS-Addressing

Typically,  Web Services communicate over SOAP through Http. Since Http is stateless in nature, there can be a maximum of 1 complete conversation at a time. This suits well for short request-response messages where the conversation is complete. But for conversations that span multiple asynchronous or  synchronous message exchanges , there should be more information packed so that there is a callback information and a context for the message. This is standardized by the WS-Addressing specification by w3 which is available here

 
When an asynchronous process is invoked, the BPEL engine either invokes a new process or resumes a running process. It does this by looking at the Address information in the header of the SOAP message. A sample header can be seen below (it is taken from the w3 spec referred above).

 
Request
<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
<S:Header>
<wsa:MessageID>uuid:6B29FC40-CA47-1067-B31D-00DD010662DA </wsa:MessageID>
<wsa:ReplyTo>
<wsa:Address>http://business456.example/client1</wsa:Address>
</wsa:ReplyTo>
<wsa:To>http://fabrikam123.example/Purchasing</wsa:To>
<wsa:Action>http://fabrikam123.example/SubmitPO</wsa:Action>
</S:Header>
<S:Body>
...
</S:Body>
</S:Envelope>

 
Note that the request has ReplyTo as the response end point and the context for the conversation as MessageID.

 
Response
<S:Envelope xmlns:f123="http://www.fabrikam123.example/svc53">
<S:Header>
<wsa:MessageID>uuid:aaaabbbb-cccc-dddd-eeee-wwwwwwwwwww</wsa:MessageID>
<wsa:RelatesTo>uuid:6B29FC40-CA47-1067-B31D-00DD010662DA </wsa:RelatesTo>
<wsa:To S:mustUnderstand="1">
http://business456.example/client1
</wsa:To>
<wsa:Action>http://fabrikam123.example/mail/DeleteAck</wsa:Action>
</S:Header>
<S:Body>
<f123:DeleteAck/>
</S:Body>
</S:Envelope>

 
Note that the response has RelatesTo as the context for the conversation.

 
All additional message exchanges in this conversations only require the RelatesTo element as the BPEL engine can invoke the process instance with this information.

Other informative artciles

Tuesday, December 15, 2009

Service Specification Template

If you are looking for a Service defnition template then the following should be a good place to start with and customize it accordingly
  1. This is available from CBDI

Monday, November 16, 2009

Web Services Security

A common question that is asked is how security is implemented in Web Services.

I am copying the overview from this article

Overview of Information Security
It is important to have a general understanding of information security prior to addressing elements of web services security. There are six general security services that encompass the various functions required of a security facility. These can also be considered as requirements that define information security:


  1. Authentication: Ensures that the sender and receiver are who they claim to be. Mechanisms such as username/password, smart cards, and Public Key Infrastructure (PKI) can be used to assure authentication.
  2. Authorization or Access Control: Ensures that an authenticated entity can access only those services they are allowed to access. Access control lists are used to implement this.
  3. Availability: Requires that uninterrupted services are provided to authenticated and authorized users.
  4. Confidentiality: This assures that information in storage and in-transit are accessible only for reading by authorized parties. Encryption is used to assure message confidentiality.
  5. Integrity: Ensures that information, either in storage or in-transit cannot be modified intentionally or unintentionally. Digital signatures are used to assure message integrity.
  6. Nonrepudiation: Requires that neither the sender nor the receiver of a message be able to legitimately claim they didn't send/receive the message.
I am listing some of the other interesting articles that I found on  this subject
  • This article is a good place to start at.
  • This one by Axis covers the different types of attacks.
  • This one shows the solution in code.
 Some important excerpts from this article are copied below
WS-Security from OASIS defines the mechanism for including integrity, confidentiality, and single message authentication features within a SOAP message. WS-Security makes use of the XML Signature and XML Encryption specifications and defines how to include digital signatures, message digests, and encrypted data in a SOAP message.

Security Assertion Markup Language (SAML) from OASIS provides a means for partner applications to share user authentication and authorization information. This is essentially the single sign-on (SSO) feature being offered by all major vendors in their e-commerce products. In the absence of any standard protocol on sharing authentication information, vendors normally use cookies in HTTP communication to implement SSO. With the advent of SAML, this same data can be wrapped inside XML in a standard way, so that cookies are not needed and interoperable SSO can be achieved.

Saturday, November 14, 2009

Adapters - Database and File Adapters

Oracle SOA Suite comes along with some adapters that adapt the underlying Component and wraps it as a Service. Some of the Adapters that are shipped with the application are Database Adapter, File Adapter, JMS Adapter, etc.
Oracle makes the access to the underlying Services easy by wrapping them as Web Services.(There is a WSDL created for each operation you make). It is very tempting to use these adapters. But,thought should be applied if this is the best design. For example, in the case of Database Adapters, it is always better to use the existing Web Services to retrieve the required data. If the Web Service does not exist and if it is in our control then it would be better to write the business logic and expose that as a Web Service. This will increase the maintainablity and reusability of this Service. I think the Database Adapter should be used when all the above options are not feasible. Even when used, it may be a better practice to create this a Web Service and assign them a suitable namespace so that they can be categorised properly.

I was recently asked if a Database Adapter can be used to poll for Orders in the Order table. My solution would be to first see if a trigger can be written on the table to publish a JMS message on the receipt of a new order. I heard that this was possible and found some information here. (Haven't tried it yet though).

Monday, November 9, 2009

SOA Suite 11g Components

The SOA Suite primarily comprises of BEA Application Server(J2EE) where the following Service Engines are embedded
  • BPEL
  • Mediator
  • Business Rules
  • Human Workflow
Oracle Service Bus is another important part of the SOA Suite but comes as a separate application.

The other helpful components/frameworks are
  • Web Service Manager - where policies are defined and enforced
  • B2B - A protocol engine that provides Business to Business communicaton over a variety of protocols like EDI, HL7, etc.
  • Adapters - Adapts non service based components as services. Examples are Database Adapter, File Adapter, JMS Adapter, eBusiness Suite Adapter.

Managing/Monitoring Tools
  • Enterprise Manager - A web based console to manage all fusion mddleware components
  • Business Activity Monitoring(BAM) - activity monitoring tool
The IDE to develop the SOA application is Java Developer. There is also an Eclipse plugin.

Mediator

Mediator is a new component(originally Oracle Service Bus before it was replaced by the AcquaLogic Bus)that has been added to Oracle SOA Suite 11g.

This article explains the difference between Mediator and OSB.
The "The Big BPEL-ESB-OSB cook-off" by ToddBiske analyses the role of each one.


What does the Mediator do?
  • It mediates components/services within an SOA Composite Application.
  • Routes the requests to the Services
  • Data Transformation between formats and protocols
  • It DOES NOT do service localisation and it cannot act as a Gateway to the Services.
How is it different from Oracle Service Bus?
  • The main difference is in the scope. Mediator performs intra-composite mediation while Oracle Service Bus performs inter-composite mediation which means that it mediates different composites together.
What should be done by a Mediator?
  • In Oracle, every BPELProcess is a Composite Service. This Composite could be invoking multiple BPEL Processes or Components. The Contract is defined at the Composite Service and the Mediator plays the role of mediation between this Contract and the various contracts for other components within the Composite. 
  • I think that it is a good practice to create a Mediator in all Composites even if the Composite has a single BPEL Process. The Mediator will help take care of additional operations that could be added to this Service in future.
  • I think that it is a good practice to do all data transformations at the Mediator.
  • Mediator can also perform routing of requests to different Services. But, I think that one should explore if this can be delegated to BPEL as its core stength is to orchestrate the services.
  • Anything that does not belong to a process has to be extracted out and put in the Mediator. For example, if the process needs the data in a certain format then that transformation can be done at the Mediator or the OSB but not in the BPEL.

Thursday, October 8, 2009

Fresh Air over Oracle Fusion Middleware

There is a lot of confusion over what Oracle Fusion Middleware is and what it comprises of. Google it and a few Oracle websites come up that are targeted for the CEOs and the CTOs which makes less sense for  technical folks. Here are some helpful podcasts Fusion Podcast1, Fusion Podcast2

  To keep it simple, my interpretation is that Oracle Fusion Middleware is a collection of technologies that are based on SOA technology platform that help the Customer develop, integrate, manage and monitor applications.

Oracle Fusion Middleware 11g

The Oracle Fusion Middleware11g is a fusion of technologies between Oracle and BEA products. I am listing the primary technologies that form the crux of this middleware and am also listing the origin of the technology which can help in understanding better. The SOA products of BEA were once called AcquaLogic Service Bus, etc.
  • Application Server from BEA which is called Oracle Weblogic Server. The Oracle Application Server based on oc4j does not seem to have found a place here.
  • Content Server from Oracle
  • Identity Manager from Oracle
  • Business Intelligence from Oracle
  • Transaction Processing from BEA which is Tuxedo
  • SOA Suite
    • BPEL Process Manager from BEA
    • Enterprise Service Bus from BEA
    • BAM from Oracle
    • Web Services Manager from Oracle
    • Business Rules from Oracle
Oracle Fusion Applications
It is the re implementation of Oracle's EBusiness Suite, Siebel, PeopleSoft and JDEdwards Enterprise as a single application.

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. 

Thursday, September 10, 2009

Oracle SOA Suite 11g Reference Documentation

Here are some of the useful links I found on the Oracle SOA 11g.  I shall keep updating them. Please drop a comment if you know of any.

Oracle Developers Guide for SOA Suite 
http://download.oracle.com/docs/cd/E14571_01/integration.1111/e10224.pdf

Oracle BPEL Documentation 


Oracle Business Rules Documentation


BPEL Blogs
http://orasoa.blogspot.com/2007/05/getting-started-with-oracle-soa-bpel.html

http://dietrichschroff.blogspot.com/search/label/BPEL


Oracle SOA 11g Memory Requirements

For folks interested in installing Oracle SOA Suite 11g, please read this to check if your desktop/laptop is suitable.

I installed the Oracle SOA Suite 11g on my new laptop which has Windows Vista on a 4GB RAM. I profiled the memory hike on the start of each service. Here it is
  • When windows started up(only basic services)  with OracleXE as Service: 39%
  • Started Oracle JDeveloper 11g : 47%
  • Started Oracle Weblogic Console : 66%
  • Started Node Manager : 69%
  • Started SOA Serve : 87%
If you plan to open a Office software or run other SOA Services like BAM then this machine crawls. You may want to plan for at least 6GB RAM. If not, you will end up watching the TaskManager every minutes to see f you can kill any process .

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. 

Sunday, August 30, 2009

Understanding WSDL

This is an attempt to explain WSDL in the simplest manner

About WSDL
  • WSDL stands for Web Service Definition Language.
  • It is a contract to the web service that is expressed in XML. To understand better this can be compared to an Interface in Java or a Package in Oracle which acts as a contract between the client and the system.
Structure of WSDL (parallels are drawn to Java wherever possible)
  1. What are the capabilities of the Service? 
    • What are the operations(methods) provided by the Service and what are the messages(parameters) that each operation requires?
    • The messages can be input(parameters), output(return value) or faults(exception)
  2. How can the Service be accessed?
    • What is the protocol(SOAP) and what is the encoding(document)?
  3. Where can the Service be accessed?
    • What is the endpoint(address) of the Service?
 Illustration of the WSDL Structure
The CreditService web service developed earlier is used to illustrate