Package de.businesscode.util
Class SOAPFaultMessage
java.lang.Object
de.businesscode.util.SOAPFaultMessage
Utility class to create a SOAPFault
Due to security concerns the server should never reveal exception internals to the client,
rather respond with a general message. Generally, the RequestLifeCycleFilter
does
so in case a request failed to process due to a thrown exception.
However, sometimes you want to respond with a business-exception to the client (yet yielding a positive http response status) so it knows what went wrong and why. In such a case you can handle a business exception in your servlet implementation and respond with a SOAPFault using this class.
For debugging purposes, everytime a new instance is constructed, a log record is ussued at DEBUG level provdiding detail data about the cause.
-
Constructor Summary
ConstructorsConstructorDescriptionSOAPFaultMessage
(Document requestDocument, String requestURL, Throwable faultException, String message) SOAPFaultMessage -
Method Summary
Modifier and TypeMethodDescriptionjakarta.xml.soap.SOAPMessage
static boolean
writeSOAPFaultToHTTPResponse
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Exception faultException, String faultMessage) Convenience method to write a SOAP message response.static boolean
writeSOAPFaultToHTTPResponse
(jakarta.servlet.http.HttpServletResponse resp, Document requestDocument, String requestURL, Throwable faultException, String faultMessage) Convenience method to write a SOAP massage response.void
writeTo
(OutputStream out)
-
Constructor Details
-
SOAPFaultMessage
public SOAPFaultMessage(Document requestDocument, String requestURL, Throwable faultException, String message) throws jakarta.xml.soap.SOAPException SOAPFaultMessage- Parameters:
requestDocument
- - optional request document to serialize into SOAPFaultrequestURL
- - optional URL to appear in SOAPFaultfaultException
- - optional exception caused this faultmessage
- - optional literal message provided as FaultReason in SOAPFault- Throws:
jakarta.xml.soap.SOAPException
-
-
Method Details
-
writeSOAPFaultToHTTPResponse
public static boolean writeSOAPFaultToHTTPResponse(jakarta.servlet.http.HttpServletResponse resp, Document requestDocument, String requestURL, Throwable faultException, String faultMessage) Convenience method to write a SOAP massage response. The responseOutputStream must not be opened yet. It captures all Exceptions happening during that and writes them to log. The http response status is NOT set by this method. The response content-type is set to 'text/xml'.- Parameters:
resp
-requestDocument
- - optional request document to serialize into SOAPFaultrequestURL
- - optional URL to appear in SOAPFaultfaultException
- - optional exception caused this fault, must not reveal security relevant factsfaultMessage
- - optional literal message provided as FaultReason in SOAPFault must not reveal security relevant facts- Returns:
- true if exception was thrown, false if a SOAPFault could not be produced an an error log was created instead
-
writeSOAPFaultToHTTPResponse
public static boolean writeSOAPFaultToHTTPResponse(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Exception faultException, String faultMessage) Convenience method to write a SOAP message response. The responseOutputStream must not be opened yet. It captures all Exceptions happening during that and writes them to log. The http response status is NOT set by this method. The response content-type is set to 'text/xml'.- Parameters:
request
-response
-faultException
- - optional exception caused this fault, must not reveal security relevant factsfaultMessage
- - must not reveal security relevant facts- Returns:
- true if exception was thrown, false if a SOAPFault could not be produced an an error log was created instead
-
getMessage
public jakarta.xml.soap.SOAPMessage getMessage()- Returns:
- the message
-
writeTo
- Parameters:
out
-- Throws:
jakarta.xml.soap.SOAPException
IOException
- See Also:
-
java.xml.soap.SOAPMessage#writeTo(java.io.OutputStream)
-