SoapBody body = soapMessage.getSoapBody();
String payload = "<payload xmlns='http://www.springframework.org' />";
transformer.transform(new StringSource(payload), body.getPayloadResult());
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
MockTransportOutputStream tos = new MockTransportOutputStream(bos);
String soapAction = "http://springframework.org/spring-ws/Action";
soapMessage.setSoapAction(soapAction);
soapMessage.writeTo(tos);
String result = bos.toString("UTF-8");
assertXMLEqual(
"<Envelope xmlns='http://www.w3.org/2003/05/soap-envelope'><Body><payload xmlns='http://www.springframework.org' /></Body></Envelope>",
result);
String contentType = tos.getHeaders().get(TransportConstants.HEADER_CONTENT_TYPE);
assertTrue("Invalid Content-Type set",
contentType.contains(SoapVersion.SOAP_12.getContentType()));
assertNull(TransportConstants.HEADER_SOAP_ACTION + " header must not be found",
tos.getHeaders().get(TransportConstants.HEADER_SOAP_ACTION));
assertTrue("Invalid Content-Type set", contentType.contains(soapAction));
String resultAccept = tos.getHeaders().get("Accept");
assertNotNull("Invalid accept header", resultAccept);
}