Aki the .Net Service I am calling requires specific prefix and namesapaces removed I did this finally with the code below.however there are additional two namespaces of parent node appearing in child node at some phase when ws-policy is being applied.I would like them removed I am not what phase i can remove those. This seems to be the only issue remaining for me I have fixed the prefix and namespaces for envelop and body using code below.
<ExecuteRequest xmlns="http://www.xxx.gov/2008/09" xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> To <ExecuteRequest xmlns="http://www.xxx.gov/2008/09"> public class PrintOutMsg extends AbstractSoapInterceptor { public PrintOutMsg() { super(Phase.USER_PROTOCOL); } public void handleMessage(SoapMessage message) throws Fault { SOAPMessage sm = message.getContent(SOAPMessage.class); try { SOAPPart soapPart = sm.getSOAPPart(); SOAPEnvelope soapEnv = soapPart.getEnvelope(); soapEnv.setPrefix("s"); soapEnv.removeNamespaceDeclaration("soap"); soapEnv.addNamespaceDeclaration("s", "http://www.w3.org/2003/05/soap-envelope") ; SOAPHeader sh = sm.getSOAPHeader(); sh.setPrefix("s"); sh.removeNamespaceDeclaration("soap"); SOAPBody sb = sm.getSOAPBody(); sb.removeNamespaceDeclaration("soap"); sb.setPrefix("s"); /* Does not impact at this phase need to know what phase to do rest above works fine. Some time after initila security implemented and before body encryption*/ //NodeList list = sb.getElementsByTagName("*"); NodeList nl= sb.getChildNodes(); //Node nd = nl.item(0); Element element = (Element)nl.item(0); element.removeAttributeNS("http://www.w3.org/2003/05/soap-envelope","xmlns:s"); element.removeAttributeNS("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd","xmlns:wsu"); System.out.println("NodeName:->" + element.getNodeName()); //String values = sm.getSOAPBody().getTextContent(); // System.out.println("Included values:" + values); ByteArrayOutputStream out = new ByteArrayOutputStream(); sm.writeTo(out); String mysoapMessage = new String(out.toByteArray()); System.out.println("------Soap Message START -------\n"); System.out.println(mysoapMessage); /* System.out.println("------Soap Message END -------\n"); System.out.println("------Soap Message ALTER START -------\n"); mysoapMessage=mysoapMessage.replaceAll("soap:","s:"); mysoapMessage=mysoapMessage.replaceAll("soap=","s="); System.out.println(mysoapMessage); System.out.println("------Soap Message ALTER END -------\n"); ByteArrayOutputStream out2 = new ByteArrayOutputStream(); out2.write(mysoapMessage.getBytes("UTF-8")); message.setContent(String.class,mysoapMessage); */ // message.setContent(InputStream.class,new ByteArrayInputStream(mysoapMessage.getBytes())); //message.setContent(OutputStream.class, out2); /* SOAPMessage sm2 = message.getContent(SOAPMessage.class); sm2.writeTo(System.out); */ //System.out.println("---UNENCRYPTED OUT MESSAGE START----\n"); //sm.writeTo(System.out); //System.out.println("\n---UNENCRYPTED OUT MESSAGE END----\n"); } catch (Exception e) { throw new Fault(e); } } } -- View this message in context: http://cxf.547215.n5.nabble.com/CXF-2-4-1-Client-is-giving-the-signature-or-decryption-was-invalid-tp4507027p4561817.html Sent from the cxf-user mailing list archive at Nabble.com.
