When creating and planning bpel processes, you must always consider using Fault Management.
Bpel process management provides many options and ways to handle and manage fault.
Sometimes, there can be a requirement to throw a custom fault – one that does not exist in the built in system fault that is being provided in the Throw Activity list.
In this post I will describe how to do it, in the most simple way.
I created my example in SOA suite 11g (11.1.1.6), but that’s the way to go on all bpel versions.
Start by creating a new SOA project with Asynchronous Bpel proces:
The next step is to create a new message:
(* When adding a new message you might encounter with a compilation error. See here the explanation and solution.)
- Go to the structure view
- Open the ‘Message Type’ folder, and the ‘Process WSDL’
- Click on ‘Create an object..’
- Give a name for the message
- Create a new message part and give it a name
- Choose a type for the message part (in my example I chose a simple String type)
After creating a new message type, you can now create a new variable of a message type (actually you can create 2 variables, one to initiate the required fault message, and another one for getting the error message):
After the declaration part is finished, we can go on to the process flow and add the Throw and Catch activities.
Drag a Throw activity into the flow panel. Inside the Throw activity add the following parameters:
- Name: Activity name
- Namespace URI: Here you can add any declaration you want. I added the bpel process Target Namespace, with additional identification.
- Local Part: Here also you can choose the name of the required Part.
- Fault Variable: write the variable of message type (the one declared on the previous section).
So actually, what we did until now, is creating a custom fault – one that similar to the list of provided system faults.
Now, in any step of our process we can add a catch activity, and choose the new custom fault.
Here is how to do it:
Within a scope, add a catch activity (in my example I just took a simple scenario where I added a catch to my main scope). Now you don’t have to choose a system fault, only manually add the following parameters:
- Namespace URI: give the namespace declared in the Throw activity.
- Local Part: give the local part declared in the Throw activity.
- Fault Variable: give the variable of message type (the one declared on the previous section). Remember, you’ve declared 2 – one for initialize the message fault, and one for populating the message. Here you can put the second one.
That’s it. You just need to add an assign activity before the Throw one, so you will initialize the message fault.
Just to emphasize – the purpose of this post, is to let you know and understand how to add a custom fault. From here you can use this technique for any needed requirement.
Happy Learning
By
Deepthi Reddy
No comments:
Post a Comment