assertTrue("Response is not a SOAP message", response instanceof SoapMessage);
SoapMessage soapResponse = (SoapMessage) response;
SoapBody responseBody = soapResponse.getSoapBody();
assertTrue("Response has no SOAP Body", responseBody != null);
assertTrue("Response has no SOAP Fault", responseBody.hasFault());
SoapFault soapFault = responseBody.getFault();
QName expectedFaultCode = getExpectedFaultCode(soapResponse.getVersion());
assertEquals("Invalid SOAP Fault code", expectedFaultCode, soapFault.getFaultCode());
if (expectedFaultStringOrReason != null) {
assertEquals("Invalid SOAP Fault string/reason", expectedFaultStringOrReason,
soapFault.getFaultStringOrReason());
}
}