Você está na página 1de 9

Learning SOA

The views expressed on this blog are my own and do not necessarily reflect the views of any Organisations owning these
products.I keep on doing R & D with different products in and around Middle ware stack and these posts are result of
that.Most of the post are result of my own experiments or ideas taken from other blogs sometimes information too.If in any
case You feel content is not right you can comment to remove that post.

Thursday, August 5, 2010


Fault handling in Oracle SOA Suite 11g-Example
We have already seen the theory part of fault handling as how it works,now in this section we will create a
simple scenario to throw and then take appropriate action as per fault policies.
Pre requisite for this exercise is
SOA Suite 11.1.1.2
JDeveloper 11.1.1.2

Example.
===========
Create a new project in Jdeveloper

give some logical name to BPEL process make it a synchronous bpel process and say finish.

So now your composite should look like this.Drag and drop a BPEL process in your composite

Now again make this as a synchronous BPEL process and deselect the exposed as web service option.

So now the process should look like this.

now double click on Throw fault bpel process and drag and drop a throw activity in between .NOw double
click on throw activity and choose one of the system fault

Create a fault variable also.


Once you will create it you will find that a wsdl is automatically added to your project RuntimeFault.wsdl
Now drag and drop an assign activity in between the throw and Receive input
In the assign activity assign some values to the fault Variable you have created.
So i have assigned some values as

So you bpel process which throws a fault should look like this

NOw connect the throw block with Catch Block as shown

Now go to the Catch Bpel process and drag and drop an invoke activity ,now connect the invoke activity
with the throw partnerlink as shown below

NOw add a catch block to catch the fault,this will catch the same remote fault for which you have defined
it.
NOw drag and drop a assign activity and copy the fault code to the output variable.
Again drag and drop a reply activity and send this output variable to the client.
We are doing so because we have only one client application here and we want that he should get the
error.So when we reply the output to client we are basically throwing the fault to the calling application.
So now your fault handling process is ready,now we will add our fault policy to this project.
copy your fault-binding.xml and fault-policies.xml file in the same folder where you have your
composite.xml lies
my fault-binding.xml file look something like this
<?xml version="1.0" encoding="UTF-8"?>
<faultPolicyBindings version="2.0.1"
xmlns="http://schemas.oracle.com/bpel/faultpolicy"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<component faultPolicy="bpelFaultHandling">
<name>CatchFault</name>
</component>
</faultPolicyBindings>
and my fault-policies.xml file looks like
<?xml version="1.0" encoding="UTF-8"?>
<faultPolicies xmlns="http://schemas.oracle.com/bpel/faultpolicy">
<faultPolicy version="2.0.1" id="bpelFaultHandling"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.oracle.com/bpel/faultpolicy"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Conditions>
<faultName xmlns:bpelx="http://schemas.oracle.com/bpel/extension"
name="bpelx:remoteFault">

<condition>
<action ref="ora-human-intervention"/>
</condition>
</faultName>
</Conditions>
<Actions>
<!-- This is an action will mark the work item to be "pending recovery from console"-->
<Action id="ora-human-intervention">
<humanIntervention/>
</Action>
</Actions>
</faultPolicy>
</faultPolicies>

There are two important things that you need to note down
1>if you can see in your falut-binding.xml you can see an entry like
component faultPolicy="bpelFaultHandling"
this is baiscally a reference id which is passed to the fault-policies.xml so correpsonding to that
we have an entry in fault-policies.xml
faultPolicy version="2.0.1" id="bpelFaultHandling"
So the important thing is that this refernce id should match in the two files.
In my case it is bpelFaultHandling in both the case.

2>You can again see in your fault-bindings.xml an entry like this

<name>CatchFault</name>
This CatchFault is the name of the BPELProcess which is catching the fault.In my case the name of process
which is
catching fault is CatchFault.

Now again we need to make two more addition in to our composite to make him aware that fault policies
are added
<property name="oracle.composite.faultPolicyFile">fault-policies.xml</property>
<property name="oracle.composite.faultBindingFile">fault-bindings.xml</property>
This should be added just after the service tag finishes
I am just pasting my composite.xml for example.

<?xml version="1.0" encoding="UTF-8" ?>


<!-- Generated by Oracle SOA Modeler version 1.0 at [8/6/10 8:31 AM]. -->
<composite name="BpelCatchFault" revision="1.0" label="2010-08-06_08-31-45_093"
mode="active" state="on" xmlns="http://xmlns.oracle.com/sca/1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:orawsp="http://schemas.oracle.com/ws/2006/01/policy"
xmlns:ui="http://xmlns.oracle.com/soa/designer/">
<import namespace="http://xmlns.oracle.com/FaultHandling_jws/BpelCatchFault/CatchFault"
location="CatchFault.wsdl" importType="wsdl"/>
<import namespace="http://xmlns.oracle.com/FaultHandling_jws/BpelCatchFault/ThrowFault"
location="ThrowFault.wsdl" importType="wsdl"/>
<service name="catchfault_client_ep" ui:wsdlLocation="CatchFault.wsdl">
<interface.wsdl
interface="http://xmlns.oracle.com/FaultHandling_jws/BpelCatchFault/CatchFault#wsdl.interface(CatchFaul
t)"/>
<binding.ws
port="http://xmlns.oracle.com/FaultHandling_jws/BpelCatchFault/CatchFault#wsdl.endpoint(catchfault_clie
nt_ep/CatchFault_pt)"/>
</service>
<property name="oracle.composite.faultPolicyFile">fault-policies.xml</property>
<property name="oracle.composite.faultBindingFile">fault-bindings.xml</property>
<component name="CatchFault">
<implementation.bpel src="CatchFault.bpel"/>
</component>
<component name="ThrowFault">
<implementation.bpel src="ThrowFault.bpel"/>
</component>
<wire>
<source.uri>catchfault_client_ep</source.uri>
<target.uri>CatchFault/catchfault_client</target.uri>
</wire>
<wire>
<source.uri>CatchFault/ThrowFault.throwfault_client</source.uri>
<target.uri>ThrowFault/throwfault_client</target.uri>
</wire>
</composite>

NOw you are done with your BPEL process.


Compile and deploy this project to your application server.
ONce deployed invoke the process you will get an option like this in the em console

Here we are getting an option of manual recovery as we have defined in our fault policy for manual
intervention.Let me know if you have issues in it.

Você também pode gostar