class SoapMessageManager {

    public Document wrapWithSoapEnvelope(Element element) {
        DocumentBuilder documentBuilder;
        try {
            documentBuilder = newDocumentBuilder();
        } catch (ParserConfigurationException e) {
            LOG.error("*** ALERT: Failed to create a document builder when trying to construct the the soap message. ***", e);
            throw new RuntimeException(e);
        }
        Document document = documentBuilder.newDocument();
        document.adoptNode(element);
        Element envelope = document.createElementNS("http://schemas.xmlsoap.org/soap/envelope/", "soapenv:Envelope");
        Element body = document.createElementNS("http://schemas.xmlsoap.org/soap/envelope/", "soapenv:Body");
        envelope.appendChild(body);
        body.appendChild(element);
        document.appendChild(envelope);

        return document;
    }

}