### Question:
SoapPayloadIO implements IPayloadIO<SOAPEnvelope> { @Override public SOAPEnvelope unmarshall(InputStream input) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); factory.setValidating(false); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(input); SOAPElement soapElement = SOAPFactory.newInstance().createElement(doc.getDocumentElement()); SOAPEnvelope envelope = (SOAPEnvelope) soapElement; return envelope; } SoapPayloadIO(); SOAPEnvelope parse(InputStream input); SOAPEnvelope parse(byte [] bytes); @Override SOAPEnvelope unmarshall(InputStream input); @Override SOAPEnvelope unmarshall(byte[] input); @Override byte[] marshall(SOAPEnvelope data);  }### Answer:
@Test public void testUnmarshall_Simple() throws Exception { String xml = "<?xml version=\"1.0\"?>\r\n" + "<soap:Envelope xmlns:soap=\"http: " <soap:Header>\r\n" + " <ns1:CustomHeader xmlns:ns1=\"urn:ns1\">CVALUE</ns1:CustomHeader>\r\n" + " </soap:Header>\r\n" + " <soap:Body>\r\n" + " <m:GetStockPrice xmlns:m=\"http: " <m:StockName>IBM</m:StockName>\r\n" + " </m:GetStockPrice>\r\n" + " </soap:Body>\r\n" + "</soap:Envelope>"; byte [] xmlBytes = xml.getBytes(); SoapPayloadIO io = new SoapPayloadIO(); try (InputStream is = new ByteArrayInputStream(xmlBytes)) { SOAPEnvelope envelope = io.unmarshall(is); Assert.assertNotNull(envelope); Assert.assertEquals("Envelope", envelope.getLocalName()); Assert.assertEquals("http: SOAPHeader header = envelope.getHeader(); Assert.assertNotNull(header); Iterator<?> allHeaderElements = header.examineAllHeaderElements(); Assert.assertTrue(allHeaderElements.hasNext()); SOAPHeaderElement cheader = (SOAPHeaderElement) allHeaderElements.next(); Assert.assertNotNull(cheader); Assert.assertEquals("CVALUE", cheader.getTextContent()); } }