Collogues, i have cycle which create soap xml with nessesary structure (don't ask about the structure)
log.info("Body elements: "); NodeList nodeList = body.getElementsByTagName("*") ; for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { log.info(node.getNodeName()); if (node.getNodeName().equals("ns2:request") ) { log.info("Set namespace and prefix for " + node.getNodeName()); SOAPElement childX = (SOAPElement) node; childX.removeNamespaceDeclaration(childX.getPrefix()) ; childX.addNamespaceDeclaration("ns3", "http://mayacomp/Generic/Ws"); childX.setPrefix("ns3"); } else { if (node.getNodeName().equals("ns2:in") ) { log.info("Remove namespace for " + node.getNodeName()); SOAPElement childX = (SOAPElement) node; childX.removeNamespaceDeclaration(childX.getPrefix()) ; childX.addNamespaceDeclaration("", ""); childX.setPrefix(""); } SOAPElement childX = (SOAPElement) node; childX.removeNamespaceDeclaration(childX.getPrefix()) ; childX.setPrefix(""); } } } As a result I receive xml:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <ns3:request xmlns:ns3="http://mayacomp/Generic/Ws"> <in xmlns="http://mayacomp/Generic/Ws"> <requestHeader> My question is how to remove only xmlns="http://mayacomp/Generic/Ws" from <in> element and receive:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <ns3:request xmlns:ns3="http://mayacomp/Generic/Ws"> <in> <requestHeader>
No comments:
Post a Comment