Friday, May 11, 2012

ESB, BPEL using Oracle SOA Suite: Article

Getting Comfortable with Oracle SOA Suite


Getting Comfortable with Oracle SOA Suite

Before starting this white paper let me tell you that I am also like you (readers) who are from the world of Oracle, PLSQL, Oracle E-Business Suite work areas who is trying to get comfortable with the upcoming technologies related to Service Oriented Architecture. I am not an expert in SOA arena. I am going to try to put things in simple terms. Some of you will differ with my opinion of starting developments related to ESB/BPEL without fully understanding the concept but I think this can also be one way of getting to the debth of the subject by actually developing it.
For Oracle Apps folks I would suggest, just start thinking about Oracle Workflow. All things which you can do using workflow can be done using BPEL and interfaces using (FTP/Shell Script/PLSQL) can be built using ESB.
I will be using Oracle SOA Suite 10.3.1.1 and Oracle JDeveloper 10.3.3.3 software for demos/screen shots.

Defining Acronym Jargons in SOA world

When we enter the world of Service Oriented Architecture we come across various acronyms viz. XML, SOA, ESB, BPEL, WSDL, XSLT, SOAP, XSD, DTD etc. Let’s define each of them.
XML is the eXtensible Markup Language accepted by the industry as ideal vehicle for sharing structured data among applications and organizations. XML is becoming universally understood, many applications provide inputs and outputs in XML. XML makes data self describing. XML eliminates fixed formats.
XSD (XML Schema Definition), a Recommendation of the World Wide Web Consortium (W3C), specifies how to formally describe the elements in an Extensible Markup Language (XML) document.
DTD is Document Type Definition which is again one of the industry accepted way of defining XML structure.
WSDL (Web Service Definition Language) is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information. The operations and messages are described abstractly, and then bound to a concrete network protocol and message format to define an endpoint. Related concrete endpoints are combined into abstract endpoints (services).
SOAP (Simple Object Access Protocol) a message-based protocol based on XML for accessing services on the Web.
SOA A service-oriented architecture is essentially a collection of services. These services communicate with each other. The communication can involve either simple data passing or it could involve two or more services coordinating some activity. Some means of connecting services to each other is needed.
ESB is an open standards-based distributed synchronous or asynchronous messaging middleware that provides secure interoperability between enterprise applications via XML, Web services interfaces and standardized rules-based routing of documents.
BPEL (Business Process Execution Language) for Web services is an XML-based language designed to enable task-sharing for a distributed computing or grid computing environment - even across multiple organizations - using a combination of Web services.

Installing Oracle SOA Suite

Download SOA Suite installable soa_windows_x86_101310_disk1.zip from oracle.com. Unzip the file in C:\OracleSOAInstall and run setup.exe. During installation you will get two options viz. Basic Install and Advanced Installation. Generally SOA Suite needs a database for installation. If Basic installation is selected then it automatically installs Oracle Database Lite on the machine while Advanced Installation needs Oracle Database 10G (10.2.0.3 or higher). For advanced installation, oracle database needs to have following schemas ORAESB, ORABPEL and ORAWSM.
Basic installation installs following components
· Oracle Containers for J2EE
· Oracle SOA Suite including Oracle BPEL Process Manager, Oracle Enterprise Service Bus (ESB), Oracle Web Services Manager (OWSM), and Oracle Business Rules.
· Oracle Enterprise Manager 10g Application Server Control
· Oracle Process Manager and Notification Server
· OC4J Java Single Sign-On
Advanced installation includes all the above components along with Oracle HTTP Server with SSL Support.
I would suggest not going for advanced installation if you are installing Windows XP Professional desktop/laptop because I always found issues Oracle Web Services Manager and Oracle BPEL manager during advanced installation. Using Basic installation as well at the Oracle BPEL Process Manager fails to configure at the end of installation but without exiting installation screen you can restart SOA Suite using windows start menu and retry BPEL process manager configuration.
During installation please make a note of Application Server Instance Name (e.g. SOA_AS) and administrator username oc4jadmin and password. This will be needed all the time for login on to Application Server Console, BPEL Console, ESB Console and WSM Console.
After Basic installation, application server is accessible at URL http://localhost:8888 or http://<machine>:<port> where you will find all the links to BPEL Process Manager, Web Services Manager Console and ESB Console.

Application Service Control

  • Click on Application Server Control, enter username (oc4jadmin) and password and make sure all services are running. If any of the service status is down then you can start the service by clicking start button.
  • Click on HomeĆ Applications to which displays list of all applications.
  • Click on Web Services Link to display all deployed web services

Configuring the Container

Once you install Oracle SOA Suite, you need to create a connection pool, data source, and database adapter, Oracle Applications Adaptor
  1. Point your browser to the Enterprise Manager for your installation of Oracle SOA Suite using URL http://<machine>:<port> e.g. http://localhost:8888
  2. From the right-hand side Manage Your SOA Suite portlet, click the Application Server Control link. The Application Server Control Console displays the administrator logon dialog box.
  3. Enter oc4jadmin as username and its password

Connection Pool and Data Source

  1. Create a connection pool and JDBC data source for the OC4J instance. Data source is used to get a connection to a database server. You must define one connection pool and its connection factory.
    1. Select the home OC4J link, which takes you to OC4J home page
    2. Click on Administration Link


    1. In Services > JDBC Resources, click the Go To Task icon to navigate to JDBC Resources page


    1. In the Connection Pools section, click the Create button to navigate to connection pool navigation page

    1. Accept defaults, and click Continue.
    2. Enter the connection pool name, Database SID, User Name password etc.


    1. Test the connection. If connection is successful then click finish
    2. Under Data Sources, click Create (Similar to Step c) and navigate to Create Data Sources screen. Accept default and click continue
    1. Enter values for Data Source Name and JNDI Location (Please note this JNDI name should be used same as JDNI Name while using DB adaptor in Oracle JDeveloper)
    2. Click Finish to complete Creation of data source
    3. Create a similar Data Source using APPS username for connecting to Oracle E-Business Suite Database. This data source will be used for creating Database Adaptor and Apps Adaptor

Adaptors in SOA Suite

In SOA world, systems talk to each other through various adaptors. In the context of an SOA an adapter is an intermediary service that bridges incompatible data formats between services and its clients. An adapter often also acts as a faƧade or technology gateway. Oracle SOA suite is shipped with various such adaptors given in following screenshot

In this article we will take a look at how to setup DbAdaptor, AppsAdaptor, File Adaptor and FTP Adaptor

Database Adaptor

  1. In Application Server Console, click on OC4J: home-->Applications
  2. Click on Default Application to arrive at screen displayed above
  3. Click DbAdaptor link and then click connection factories link
  4. Click Create Button to create connection factory. Click Continue
  5. Specify Connection Factory JNDI Name and most important xADataSourceName same as Data Source JNDI Name created few steps before i.e. eis/DB/APPS_SOADB


Oracle Applications Adaptor
  1. In Application Server Console, click on OC4J: home-->Applications
  2. Click on Default Application to arrive at screen displayed above
  3. Click AppsAdaptor link and then click connection factories link
  4. Click Create Button to create connection factory. Click Continue

  1. Specify Connection Factory JNDI Name and most important xADataSourceName same as Data Source JNDI Name created few steps before i.e eis/DB/APPS_SOADB

File Adaptor

File adaptors is already setup with default installation and can be used as it is while developing ESB or BPEL applications. For File Adaptor the JNDI location is eis/FileAdapter which can be used for writing files at any location on machine hosting Oracle SOA Suite

FTP Adaptor

FTP Adaptors can be created for each destination machine by setting up configuration properties needed for FTP process.

Conclusion

This much knowledge of configuring Oracle SOA Suite is sufficient to start developing applications based on ESB and BPEL. In the next article we will take an overview of Oracle JDeveloper 10.1.3.0 and various services, Process Activities involved in developing ESB and BPEL projects.


########

FAULT POLICY IN SOA 11G

Fault Policy Overview


* Since 10.1.3.3
* Catches all faults from an invoke activity (both run time and business faults)
* Important: overrides all catch activities in BPEL process.
* A fault policy defines conditions and their corresponding fault recovery actions.
* Fault policies are defined in multiple files under directory:
- bpel\domains\default\config\fault-policies
* XSD files are:
- bpel\system\xmllib\fault-policy.xsd
- bpel\system\xmllib\fault-policy-binding.xsd
* A fault policy can be associated at the following levels:
- Partner link
- Port type
- Process level via bpel.xml
- Domain level via fault-bindings.xml
* Fault policy binding order:
-> bpel.xml: partner link -> port type -> process
-> domain: partner link -> port type -> process
-> Catch blocks defined in bpel diagram.

SOA Fault Types

Business Faults

* Programmer defined.
* Defined in WSDL.

Runtime Faults

* Predefined, e.g.
- remoteFault
- bindingFault
* Infrastructure faults, e.g.
- Service down
- Network outage
* Data format errors

Design a Fault Policy

Create a Fault Policy File

* Create policy file (e.g. my-policies.xml) in bpel\domains\domain_name\config\fault-policies directory

Define conditions

* Conditions are based on faultName. e.g.
 
<faultName
  xmlns:bpelx="http://schemas.oracle.com/bpel/extension"
  name="bpelx:remoteFault">
 
* Multiple conditions are allowed for a single faultName
- if so, conditions are evaluated sequentially
 
  <condition>
    <test>$fault.code/code="WSDLReadingError"</test>
    <action ref="ora-terminate"/>
  </condition>
  <condition>
    <action ref="ora-java"/>
  </condition>
 
* Each condition has
- one test section which is an XPath expression against fault variable
 
    <test>$fault.code/code="WSDLReadingError"</test>
 
- one action section which references to the action defined in the same file
 
    <action ref="ora-terminate"/>
 
- No test condition catches all
 
<condition>
  <action ref="ora-rethrow"/>
</condition>
 
- No faultName catches all faults
 
<faultName > . . . </faultName>
 

Define actions

* See examples below.

Fault Policy Examples

* Conditions
 
<Conditions>
  <!-- when bpelx:remoteFault, retry -->
  <faultName
    xmlns:bpelx="http://schemas.oracle.com/bpel/extension"
    name="bpelx:remoteFault">
    <condition>
      <action ref="ora-retry"/>
    </condition>
  </faultName>
 
  <!-- when bpelx:bindingFault, rethrow fault -->
  <faultName
    xmlns:bpelx="http://schemas.oracle.com/bpel/extension"
    name="bpelx:bindingFault">
    <condition>
      <action ref="ora-rethrow-fault"/>
    </condition>
  </faultName>
</Conditions>
 
* Actions
 
<!-- retry Action -->
<Action id="ora-retry">
  <retry>
    <retryCount>8</retryCount>
    <retryInterval>2</retryInterval>
    <retryFailureAction ref="ora-terminate"/>
    <exponentialBackoff/>
  </retry>
</Action>
 
<!-- replayScope Action -->
<Action id="ora-replay-scope">
  <replayScope/>
</Action>
 
<!-- rethrowFault Action -->
<Action id="ora-rethrow-fault">
  <rethrowFault/>
</Action>
 
<!-- humanIntervention Action -->
<Action id="ora-human-intervention">
  <humanIntervention/>
</Action>
 
<!-- abort Action -->
<Action id="ora-terminate">
  <abort/>
</Action>
 
<!-- Custom Java Action -->
<Action id="ora-java">
  <javaAction className="mypackage.myClass"
    defaultAction="ora-terminate"
    propertySet="propSet1">
    <returnValue value="R_TRM"
      ref="ora-terminate"/>
    <returnValue value="R_THRW"
      ref="ora-rethrow-fault"/>
  </javaAction>
</Action>
- Java class must implement IFaultRecoveryJavaClass interface
 
public interface IFaultRecoveryJavaClass {
  public void handleRetrySuccess(IFaultRecoveryContext ctx );
  public String handleBPELFault(IFaultRecoveryContext ctx );
}

Associate a Fault Policy

* Process level
- Configured in bpel.xml file.
- Only one fault policy can be bound to a process, port type, or partner link.
- Multiple port types or partner links can be bound to a single fault policy.
 
<faultPolicyBindings>
  <!-- Fault on any plink/port type not specified -->
  <!-- below uses policy BillingFaults -->
<process faultPolicy="BillingFaults"/>
<partnerLink xmlns:credit="http://services.otn.com" faultPolicy="CRM_
    ServiceFaults">
      <!-- Fault on these 2 plink will use policy CRM_ServiceFaults -->
      <name>UnitedLoanService</name>
      <name>StarLoanService</name>
 
    <!----Fault on these 2 port types uses policy CRM_ServiceFaults -->
<portType>credit:CreditRatingService</portType>
<portType xmlns:united="http://services.uninted.com/loan">
    united:UnitedLoanService</portType>
  </partnerLink>
<partnerLink faultPolicy="myOtherFaults">
    <!-- Fault on this plink uses policy myOtherFaults -->
    <name>AnotherPartnerLink</name>
  </partnerLink>
</faultPolicyBindings>
 
* Domain level
- Configured in OracleAS_2\bpel\domains\default\config\fault-bindings.xml file.
 
  <!-- all processes in this domain use DefaultPolicy -->
<process faultPolicy="DefaultPolicy"/>
 
 
<partnerLink faultPolicy="DefaultPolicy">
    <!-- all invoke faults at partner link creditRatingService use DefaultPolicy -->
    <name>creditRatingService</name>
  </partnerLink>
 
 
<partnerLink faultPolicy="DefaultPolicy">
    <!-- all invoke faults at specific port type use DefaultPolicy -->
<portType
      xmlns:db="http://xmlns.oracle.com/pcbpel/adapter/db/insert/">db:insert_plt</portType>
  </partnerLink>
 

Human Intervention in Oracle BPEL Control

* Login BPEL console
* Click Activities tab
* Seach activities based on states
- All States: Displays all activities, regardless of their state.
- Open: Displays only open activities.
- Completed: Displays only completed activities.
- Cancelled: Displays only cancelled activities.
- Stale: Displays only stale activities.
- Pending: Displays only pending activities.
* Click the faulted activity
* Optionally change the variable values
* Select action to take
- Retry: Retries the activity with an option to provide a retry success action.
- Abort: Terminates the process instance of the faulted activity.
- Rethrow: Rethrows the exception and allows the BPEL fault handlers (catch branches) to handle the fault.
- Replay: Replays the scope in which the fault occurred.
- Continue: Skips the activity. The framework assumes the activity completed with no fault.
* Click the Recover button.

########