Created
May 13, 2015 15:44
-
-
Save jonashackt/132eed6d5763ad50478a to your computer and use it in GitHub Desktop.
Apache CXF Interceptor for Custom SoapFaults Part 2. - Checking for relevant Exceptions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
private boolean containsFaultIndicatingNotSchemeCompliantXml(Throwable faultCause, String faultMessage) { | |
if(faultCause instanceof UnmarshalException | |
// 1.) If the root-Element of the SoapBody is syntactically correct, but not scheme-compliant, | |
// there is no UnmarshalException and we have to look for | |
// 2.) Missing / lead to Faults without Causes, but to Messages like "Unexpected wrapper element XYZ found. Expected" | |
// One could argue, that this is syntactically incorrect, but here we just take it as Non-Scheme-compliant | |
|| isNotNull(faultMessage) && faultMessage.contains("Unexpected wrapper element")) { | |
return true; | |
} | |
return false; | |
} | |
private boolean containsFaultIndicatingSyntacticallyIncorrectXml(Throwable faultCause, String faultMessage) { | |
if(faultCause instanceof WstxException | |
// If Xml-Header is invalid, there is a wrapped Cause in the original Cause we have to check | |
|| isNotNull(faultCause) && faultCause.getCause() instanceof WstxUnexpectedCharException | |
|| faultCause instanceof IllegalArgumentException) { | |
return true; | |
} | |
return false; | |
} | |
//... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment