SOAPMessage saajResponse = response.getSaajMessage();
String[] headerValues = saajResponse.getMimeHeaders().getHeader(RESPONSE_HEADER_NAME);
Assert.assertNotNull("Response has no header", headerValues);
Assert.assertEquals("Response has invalid header", 1, headerValues.length);
Assert.assertEquals("Response has invalid header values", RESPONSE_HEADER_VALUE, headerValues[0]);
StringResult result = new StringResult();
Transformer transformer = transformerFactory.newTransformer();
transformer.transform(response.getPayloadSource(), result);
assertXMLEqual("Invalid response", RESPONSE, result.toString());
}
finally {
connection.close();
}
}