Handling SOAP Fault in IBM BPM webserivce integration

This is one area which most of us including are under the impression that SOAP Faults can not be handled with the web service integration of IBM BPM. It is very much untill the version8.0, but the support has been provided starting from v8.0.1. The link below tells you on high level on how to capture the soap fault using the error event in IBM BPM.
IBM Knowledge Center.

your WSDL operation looks like this, similar to what is shown in the above link.
Operation Element in WSDL (Fig - 1)

What does this link won't tell you and you need to know in order to make this work ?

It took us nearly two days to figure out how the soap fault should be in order to catch that from the IBM BPM web service integration component and thought of sharing it with you all.
SOAP Fault can be a modeled fault or an un-modeled fault. 
Modeled fault is a user defined fault message when an exception is caught in the code and sent as a part of SOAP Fault, wrapped inside the element <detail/>.  
SOAP Fault with modeled Fault (Fig -2)
Un-modeled fault is system generated fault which is sent when some unexpected / unhandled exception occurs, which looks like the one in below screen shot.

SOAP Fault with un-modeled Fault (Fig -3)

One important thing to remember here is that <faultcode/>, <faultstring/> and <detail> in the SOAP Fault should be as shown in the above figures with out namespace. It should not be like this <soapenv:faultcode/>,<soapenv:faultstring/> (with namespace). If it is with the name space the internal code will throw a NullPointerException instead of catching the fault message.
  1. Catching modeled Fault Exception

Below image shows on how configure the error event to catch the modeled Fault.
WS - Integration Catch specific Errors ( Fig-4 )

In this you need to use catch specific Errors option of error event. The Error Code should match fault name from the WSDL as shown Fig-1. You can also select the error code as shown below.
Catch Specific Error Configuration (Fig -5)
And tw.local.error should be of type "ConverterMyConverterException" as shown at Error mapping in above figure.

error object automatically populated for modeled error (Fig-6)

2. Catching un-modeled Exception

Below image shows how to model generic errors with WS integration to catch the Fault as shown in Fig - 3.

Error Event Configuration (Fig -7)
When this is used, the captured error will go in to tw.system.error as an xml, which then has to be parse to retrieve the faultcode and faultstring as shown below.

catch and parse un-modeled Fault (Fig - 8)
error object populated after parsing tw.system.error (Fig-9)

You can use the method of parsing tw.system.error to retrieve the faultcode and faultstring from the SOAP Fault even while catching specific errors which is described in section 1 above.
When you soap WS can contain both modeled and un-modeled SOAP Fault, you can use the mechanism some thing like below to handle specific and generic errors.

Hope this helps !!


No comments:

Post a Comment