Error or Fault occurs when web services return data other than what is normally expected. E.g. web service return error message instead of credit card status. In Oracle SOA Suite, mainly we have two types of faults.
When we have error or fault based on Business functions, it is known as business faults. e.g. Invalid credit card number, Invalid age etc. These faults are user defined and application specific.
Technical (Runtime) Faults:
Runtime faults are the result of problems within the running of the BPEL process service component or web service. These faults are not user-defined, and are thrown by the system. Below are the most commonly faced runtime faults in SOA Suite tool.
bindingfault: A bindingFault is thrown inside an activity if the preparation of the invocation fails. For example, the WSDL of the process fails to load. A bindingFault is not retryable. This type of fault usually must be fixed by human intervention.
remoteFault: A remoteFault is also thrown inside an activity. It is thrown because the invocation fails. For example, a SOAP fault is returned by the remote service.
In BPEL, we have some standard faults defined. these defined by WS-BPEL specifications and these are not associated with a message type or WSDL message, and can be caught without a fault variable. These faults are thrown by the systems.
In Oracle SOA Suite, we can handle the faults by following ways.
We use Catch & CatchAll blocks to handle the faults at BPEL component level. we use Catch block to handle specific fault like to handle remote fault and we use CatchAll block when we don’t know about fault as this block handle all the faults.
We can have only one CatchAll block in one BPEL process but we can have more than one Catch block in BPEL process. If we have both Catch & CatchAll block in one BPEL then Catch block executed first.
Fault Handling Framework
This is another way to handle the faults in Oracle SOA suite. Main difference between these two methods is that, in Catch Block we can only handle error at BPEL level as we can’t apply these block in other components. e.g. to handle errors in Mediator component we use Fault Handling framework not Catch blocks.
Fault handling framework only handle faults that occurs during runtime in an invoke activity in a process, the framework catches the fault and performs a user-specified action defined in a fault policy file associated with the activity.
We need following two files that for policy driven fault handling:
fault-policy.xml: This file defines one or more fault Policies with conditions and actions. In this file we define what type of error we want to handle and what action we need to perform when that fault occur. In one file, we can define more than one policy as each policy will have one unique id.
fault-bindings.xml: This file associates a policy with a composite application, a component, or a reference.