Tuesday, August 17, 2010

Error/Exception Handling in OSB

I will continue with my previous post on calling a synchronous process process from OSB

As we have seen that we were able to call the BPEL process from OSB,In this exercise we will just stop our soa server intentionally to create an error so when OSB will call the business process in SOA it will get errored out then we will capture that error.

We will create a proxy service to call this business service.





Give it some logical name ,let it be xml service and say last




SAve it.

NOw just click on edit message flow as shown



Add a new route action and edit it



Add a routing action

Communication-->Routing



Now in service choose business service that you have created.




choose the process and save all



Now activate the changes and invoke the proxy service.you will get an erro like this



AS we can see we are getting error in response document.

This is not an expected behavior as if we will be having one more proxy which will call to this proxy it will receive this error response which we don't want.


So we will add an error handler in our routing node as shown below



Add a stage and edit the stage.




now in the edit stage add two block

Add an action-->Reporting--->Log

1>LOg $fault

by default all the fault are logged in to fault variable.It can be set at error level to display the erro in the command console.

Add an action--->Flow Control --->Reply
2>Reply with success.

It won't send the error to the respone,i am not able to explain it properly but you can do a check by first selecting
with success and then with failure.in my case i am just checking Reply with Success





now save the changes and activate it.now call the proxy service again and review the result.As you can see you can now find the output response.This example will be more good if we will add one more proxy service and take request and response in pipeline .



This is just an example i have used to illustrate how fault handling can be used,its not a great example but this will atleast give you an idea on its use case.

No comments: