For a usecase i needed a construction which would give me the option to implemenent generic service error handling in which i could conditionally execute activities like alerts, reports, logging, etc
One place which will contain all the error handling logic and which could be easily extended both in implementation of the logic for handling errors and being able to easily add new errors to be handle which the metadata for this error.

In case third party applications decide to trigger new type of exceptions/faults i don’t want to change the fault handling logic of all the process which do a call to this service. I want to be able to add the to be executed logic for this new specific error to some sort of error repository together with some setup-settings.

Definition of the error repository
In our case the error repository is nothing more then a xml metadata storage which stores settings for the errors to be handled.
The definition of the metadata can be extended with other settings which can be retrieved at one central place again and logic for handling the settings will also be centrally defined.

Definition of the error handling service
In our case the error handling service will be the central point in which we retrieve instance data from the process in which the occured fault.
Based on this data we will retrieve metadata for the fault and decide in the message flow handling what the logic will be to execute.

At this point we have the list of faults together with metadata about what to execute when they occure available in the Message Flow.

In the second assign we retrieve only the the metadata from our occured fault, so we just retrieve 1 error-element from the list.

For this we execute the lookupError xquery which receives the errorList content and the errorCode and will return the error-element.
If we can’t retrieve any metadata based on the errorCode we will return a default set of metadata (the error-element of which the code = DEFAULT).
The result we will assign to the errorMetadataDetails variable.

2. conditionalReporting

In all the conditional stages we will now re-use the errorMetadataDetails variable to verify if we want to execute certain login.

If we configurated the indReporting=Y in the error repository xquery file then the if-then loginc will evaluate to the if-tree and the Report-activty will be executed.
In the same way all the other condition stages (conditionalAlert, conditionalSomethingElse) will work. We re-use the errorMetadataDetails-variable and just do a simple if-then check to see if certain logic needs to be executed.

3. constructResponse

The last step of the message flow is the step in which we construct the response of the errorHandler process back to the client process.
In this step we will be using Dynamic Xquery to be able the construct response messages based on the incoming fault.
The example of our ErrorReposity defines 2 faults and 1 default.
In case for example error BEA-380000 occures, we will use the xquery located at ErrorHandling/errorRepository/GenericFault_To_SOAPFault2 to be executed. This xquery will construct our soap fault.

To be able to use Dynamic Xquery all the to be used xquery transformations need to have the same interface. Depending on the backend system and the returning faults from it we will use different tranformation files.
But all of them will be using the input paramters ‘body, inbound and fault’. In the expression field we will use the faultTransformer-element from the errorMetadataDetails. So for every fault for which we want to create a
different fault response we do need to define a faultTransformer-value in the errorRepository.

And that’s all what is needed to implement in the errorHandler process to receive the metadata, handle the fault and construct the response.

Testcase

For this testcase we created a simple EmployeeService. Create a new proxy service based on the next wsdl/xsd content.

The first assign will assign the body to body_temp so in case of an error situation we still have the original body content stored

The second activity is the validation activity. This one we will be using lateron to trigger a fault which will be processed by the errorHandler process.
Based on the same wsdl as the proxy service i defined a new business service. In the EmployeeService proxy we will be routing to this business service.
Since we won’t be implementing any logic on this side we just update the endpoint of the business service to something useless so the route will fail on this one.
This part is used to the second fault triggering moment in our process. Also this situation will fail and the occured fault will get processed by the errorHandler.

The ‘normal’ message flow of our proxy service is now done.
Let’s have a look at the service error handler.

The first assign will use the next xquery and assign the result to errorhandler_request

Now test the process either by using the testconsole of some testclient.

The first testcase will have a valid input message. So the process will pass the Validation activity and will fail when routing to the business service.
Since we used a non-existing host in here the process will trigger a BEA-380000 fault. As we defined in the errorRepository this errorCode will have the next set of metadata configured

The generated soap fault is correct. It contains the custom_details2-element, which is generated by the GenericFault_To_SOAPFault2 transformer.
Next check the sbconsole to see if there is also a report triggered for this error (indReporting=Y).
Next check the weblogic console to see if the alert got executed (indAlert=Y). For this one i created an alert with JMS Destionation.

For the second testcase we will use an invalid input message. The validation will throw an error (BEA-382505).
Check the generated soap fault (custom_details-element should get generated now).

And verify the alert and report too, to see if they got handled correctly.

Extensibility

In our xsd definition of the errorRepository we only defined a few settings just to show how it could work.
Eventually this model can be extend with every setting you need in your error handling processes. Since all the logic of reading those settings and decide what logic to execute is defined on only
one place, the errorHandler proxy service itself, it’s little work to extend the current logic for handlin the errors with new functionality. Just a new if-then activities for new settings and you’re ready to go.

Conclusion

The functionality as defined in the blog for handling the errors and creating a single point of error processing was enough for my testcase.
I needed all the logic on one place and not in every process. I needed a single place in which i could define all the errors i wanted to handle and what actions to execute when such an error occurs.
Besides that i needed a way in which other persons could easily add new defined errors to the file and the process would just ‘handle’ them without adding extra logic to processes.
In case you don’t want someone else to manipulate the errorRepository file directly from within the sbconsole itself we could also just read the content of this file from some other external location by use of the doc() function, see this blog.

I hope the solution described will help you a bit on implementation error handling in the Oracle Service Bus.
As i’m always keen on learning from others, please leave comments on how to make the implementation better, or if the solution is totally useless please say so too

Share this:

65 Responses to “Oracle Service Bus, Generic fault handling”

I am not able to see the error code BEA 382505 even after sending the invalid XML as suggested in your test case. Can you please let me know to what could be missing. I didn’t change anything in the project.

Thanks for the reply. The error code that I see in the adminServer.log is perfectly fine, meaning it match the expected result as per the test case describe however this is not the case with SOAP UI. I see the same error code BEA382505 in SOAP UI whether I send the valid or invalid employee ID. Any reason do you know why SOAP is showing the same error code for valid and invalid ID but adminServer.log is showing the correct way.

Another quick one. Do you know the best possible way to extract the SOAP message. Currently I am sending the entire SOAP body and publishing it to my email service but I need a XQuery to just extract errorCode and route node info. I am new to XQuery so need your help.

Hi Eric.
First, thank you very much for your blog. I have read several articles and it have helped me a lot.
For generic fault handling I followed your instructions and it has worked fine. Now I wonder how I could have the definition of errors in a database.
I could use a JCA resource for access to DB, ¿is this the best option?, Can you help?

I think that’s indeed the best and easiest way to make a call to the database. You could add result caching to the db adapter to make it even more faster since most of the error configuration won’t change that often

Great Article!!Just one question here for most projects we use soa (bpel) and OSB services both. In such case do you recommend using this kind of framework for logging, auditing and error handling for both bpel and OSB components with OSB services used for this purpose.

When a service is getting invoked, does this always happen on the OSB or do clients also invoke BPEL directly ?
If it’s the first, then i would only log the error in the OSB and let BPEL propogate it back to the OSB. If you want to be able to retry both OSB and BPEL services,you will need to make the framework dynamic so you know which component logged/triggered the fault

[…] Oracle Service Bus, Generic fault handling – Oracle … – For a usecase i needed a construction which would give me the option to implemenent generic service error handling in which i could conditionally execute activities …… […]