normalizedMessage.setContent(new DOMSource(root));
if (root instanceof Element == false) { throw new IllegalStateException("Could not find body content"); } Element element = (Element) root;   for (Node parent = element.getParentNode(); parent != null; parent = parent.getParentNode()) { NamedNodeMap attributes = parent.getAttributes(); if (attributes != null) { for (int i = 0; i < attributes.getLength(); i++) { Attr att = (Attr) attributes.item(i); if (att.getName().startsWith("xmlns:") && element.getAttributes().getNamedItemNS(att.getNamespaceURI(), att.getLocalName()) == null) { element.setAttributeNS(att.getNamespaceURI(), att.getName(), att.getValue()); } } } }  normalizedMessage.setContent(new DOMSource(element));
    public void toNMS(NormalizedMessage normalizedMessage, HttpMethod method)            throws Exception {        addNmsProperties(normalizedMessage, method);        String response = method.getResponseBodyAsString();        Node node = sourceTransformer.toDOMNode(new StringSource(response));        CachedXPathAPI cachedXPathAPI = new CachedXPathAPI();        NodeIterator iterator = cachedXPathAPI.selectNodeIterator(node, "/*/*[local-name()='Body']/*");        Node root = iterator.nextNode();        normalizedMessage.setContent(new DOMSource(root));    }