Created
May 13, 2015 15:28
-
-
Save jonashackt/5282a1fdc263da6951fd to your computer and use it in GitHub Desktop.
Apache CXF Interceptor for Custom SoapFaults
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
public class WeatherServiceXmlValidationInterceptor extends AbstractSoapInterceptor { | |
//... | |
public WeatherServiceXmlValidationInterceptor() { | |
super(Phase.PRE_STREAM); | |
} | |
@Override | |
public void handleMessage(SoapMessage soapMessage) throws Fault { | |
Fault fault = (Fault) soapMessage.getContent(Exception.class); | |
Throwable faultCause = fault.getCause(); | |
String faultMessage = fault.getMessage(); | |
if (containsFaultIndicatingNotSchemeCompliantXml(faultCause, faultMessage)) { | |
LOGGER.debug(FaultConst.SCHEME_VALIDATION_ERROR.getMessage() + ": {}", faultMessage); | |
WeatherSoapFaultHelper.buildWeatherFaultAndSet2SoapMessage(soapMessage, FaultConst.SCHEME_VALIDATION_ERROR); | |
} | |
if (containsFaultIndicatingSyntacticallyIncorrectXml(faultCause, faultMessage)) { | |
LOGGER.debug(FaultConst.SYNTACTICALLY_INCORRECT_XML_ERROR.getMessage() + ": {}", faultMessage); | |
WeatherSoapFaultHelper.buildWeatherFaultAndSet2SoapMessage(soapMessage, FaultConst.SYNTACTICALLY_INCORRECT_XML_ERROR); | |
} | |
} | |
//... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment