DomPoxMessage implements PoxMessage { @Override public void writeTo(OutputStream outputStream) throws IOException { try { if (outputStream instanceof TransportOutputStream) { TransportOutputStream transportOutputStream = (TransportOutputStream) outputStream; transportOutputStream.addHeader(TransportConstants.HEADER_CONTENT_TYPE, contentType); } transformer.transform(getPayloadSource(), new StreamResult(outputStream)); } catch (TransformerException ex) { throw new DomPoxMessageException("Could write document: " + ex.getMessage(), ex); } } DomPoxMessage(Document document, Transformer transformer, String contentType); Document getDocument(); @Override Result getPayloadResult(); @Override Source getPayloadSource(); boolean hasFault(); String getFaultReason(); String toString(); @Override void writeTo(OutputStream outputStream);  }
@Test public void testWriteTo() throws Exception { String content = "<root xmlns='http: StringSource source = new StringSource(content); transformer.transform(source, message.getPayloadResult()); ByteArrayOutputStream os = new ByteArrayOutputStream(); message.writeTo(os); assertXMLEqual(content, os.toString("UTF-8")); }