Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonashackt/132eed6d5763ad50478a to your computer and use it in GitHub Desktop.
Save jonashackt/132eed6d5763ad50478a to your computer and use it in GitHub Desktop.
Apache CXF Interceptor for Custom SoapFaults Part 2. - Checking for relevant Exceptions
//...
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