206 Broker Interactions for Intra- and Inter-enterprise
Handling SOAP fault messages
Example 8-8 shows the recommended way to create and return a SOAP fault
message from the GatewayFilter.filterResponse method.
Example 8-8 Creating and returning a SOAP fault message from a filterResponse method
public FilterAction filterResponse(WSIFRequest wsifRequest, WSIFResponse wsifResponse)
throws FilterException, WSGWException, RemoteException {
// Construct the fault message
WSIFMessage faultMessage = new WSIFDefaultMessage();
faultMessage.setObjectPart(WSIFConstants.SOAP_FAULT_ACTOR,"mySoapFaultActor");
faultMessage.setObjectPart(WSIFConstants.SOAP_FAULT_CODE,"mySoapFaultCode");
faultMessage.setObjectPart(WSIFConstants.SOAP_FAULT_STRING,"mySoapFaultString");
faultMessage.setObjectPart("stackTrace","myStackTraceDetails");
faultMessage.setObjectPart("otherDetails","myOtherDetails");
// repeat faultMessage.setObjectPart("aaaa","bbbb"); for each additional detail element
// Set the fault message into the wsifResponse object
wsifResponse.setFaultMessage(faultMessage);
wsifResponse.setIsFault(true);
// Return the updated response in the filterAction object
FilterAction filterAction = new FilterAction();
filterAction.setUpdatedResponse(wsifResponse);
filterAction.setContinueProcessing(false);
return filterAction;
}
Handling exceptions for the Web Services Gateway
During normal processing of a Web service invocation, a fault message might be
generated by the target service, and is passed back to the channel to be sent to
the originator. As far as the Web Services Gateway is concerned there is no
difference between processing a normal output message and processing a fault
message.
But when an exception occurs during processing of a request, the channel needs
some way to decide what to do with the exception. What is needed is a service
that provides a pluggable handler that can look at the message, exception and
other information to decide whether the exception should be thrown back to the
originator, or whether a fault message should be constructed.
This service is not provided with the Web Services Gateway, but the gateway
does contain an interface to encapsulate such a service. The ExceptionHandler
interface allows channels to call an exception handling service, and allows the
exceptions to be reported to a third party for analysis.