private Document getSoapBodyAsDocument(SOAPBody body) { Element element = null; try { element = XMLUtils.toDOM(body.getFirstElement()); } catch (Exception e) { LOG.warn("Converting to W3C Document failed"); } return element.getOwnerDocument(); } }
private static Assertion unmarshellElement(OMElement omAssertion) throws Exception{ if(omAssertion.getLocalName().equals("Assertion")){ try{ UnmarshallerFactory factory = Configuration.getUnmarshallerFactory (); javax.xml.namespace.QName qname = omAssertion.getQName(); Unmarshaller unmarsh = factory.getUnmarshaller(qname); if(unmarsh == null){ throw new Exception("Unmarshell Exception"); } Assertion assertion; assertion = (Assertion)unmarsh.unmarshall(XMLUtils.toDOM(omAssertion)); return assertion; } catch(Exception e){ throw e ; } } return null ; }
Element elt = XMLUtils.toDOM(element);
response = XMLUtils.toDOM(responseElem);
protected static void printWSDL(final Document wsdl, final String serviceAddress, final Collection<PolicyComponent> wssPolicies, final OutputStream out) throws Exception { assert wsdl != null; // create a easyWSDL description final Description desc = WSDL4ComplexWsdlFactory.newInstance().newWSDLReader().read(wsdl); // delete imported documents desc.deleteImportedDocumentsInWsdl(new URI(serviceAddress + "?wsdl=")); // recreate a Document without imports final Document descWithoutImport = WSDL4ComplexWsdlFactory.newInstance().newWSDLWriter().getDocument(desc); // And add the WSS-Policy if exists for (final PolicyComponent wssPolicy : wssPolicies) { final OMElement policyElt = PolicyUtil.getPolicyComponentAsOMElement(wssPolicy); final Node policyNode = descWithoutImport.adoptNode(XMLUtils.toDOM(policyElt)); // Remove Apache Rampart configuration from WS-Policy final NodeList rampartConfigElts = ((Element) policyNode) .getElementsByTagNameNS("http://ws.apache.org/rampart/policy", "RampartConfig"); for (int i = 0; i < rampartConfigElts.getLength(); i++) { final Node rampartConfigElt = rampartConfigElts.item(i); rampartConfigElt.getParentNode().removeChild(rampartConfigElt); } descWithoutImport.getDocumentElement().appendChild(policyNode); } XMLPrettyPrinter.prettify(descWithoutImport, out, XMLPrettyPrinter.getEncoding(descWithoutImport)); }
response = doXmlToString(XMLUtils.toDOM(responseElem));
inputDoc = XMLUtils.toDOM(input);
OMElement newChild = TrustUtil.createCancelRequest(sct .getIdentifier(), rmd.getWstVersion()); Element newDomChild = XMLUtils.toDOM(newChild); Node importedNode = rmd.getDocument().importNode((Element) newDomChild, true); ((Element) bodyElem).replaceChild(importedNode, (Element) child);