AxiomUtils { public static SOAPEnvelope toEnvelope(Document document) { return OMXMLBuilderFactory.createSOAPModelBuilder(new DOMSource(document)).getSOAPEnvelope(); }  static OMNamespace toNamespace(QName qName, OMElement resolveElement); static String toLanguage(Locale locale); static Locale toLocale(String language); static void removeContents(OMContainer container); static Document toDocument(SOAPEnvelope envelope); static SOAPEnvelope toEnvelope(Document document);  }
@Test public void testToEnvelope() throws Exception { Resource resource = new ClassPathResource("org/springframework/ws/soap/soap11/soap11.xml"); byte[] buf = FileCopyUtils.copyToByteArray(resource.getFile()); String expected = new String(buf, "UTF-8"); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactoryUtils.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document document = documentBuilder.parse(SaxUtils.createInputSource(resource)); SOAPEnvelope envelope = AxiomUtils.toEnvelope(document); StringWriter writer = new StringWriter(); envelope.serialize(writer); String result = writer.toString(); assertXMLEqual("Invalid SOAPEnvelope generated from document", expected, result); }