Creating and returning a SOAP fault message from a filterResponse method

This topic provides an example of how to create and return a SOAP fault message from a GatewayFilter.filterResponse method.

Before you begin

Example

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; 
}

[Version 5.0.2 and later]The previous example works with both the Apache SOAP and the SOAP over HTTP channels. If you use the SOAP over HTTP channel, the previous example returns the following SOAP fault response:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <soapenv:Fault>
   <faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:mySoapFaultCode</faultcode>
   <faultstring>mySoapFaultString</faultstring>
   <faultactor>mySoapFaultActor</faultactor>
   <detail>
    <stackTrace>myStackTraceDetails</stackTrace>
    <otherDetails>myOtherDetails</otherDetails>
   </detail>
  </soapenv:Fault>
 </soapenv:Body>
</soapenv:Envelope>


Related tasks
Writing a filter for the Web services gateway
Related reference
Web services gateway - The Filter interface
Web services gateway - The gateway message context values



Searchable topic ID:   twsg_pme_wrifl_faultmsg
Last updated: Jun 21, 2007 8:07:48 PM CDT    WebSphere Business Integration Server Foundation, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.wasee.doc/info/ee/wsg/tasks/twsg_pme_wrifl_faultmsg.html

Library | Support | Terms of Use | Feedback