0 Replies Latest reply on Jan 5, 2012 7:20 PM by Juan Camilo Rincon

    Help!! Trying to remove ns1 prefix from a secured- and signed- message

    Juan Camilo Rincon Newbie

      Hello everybody!


      I newby using JBoss CXF but I have to say that it´s totally amazing.



      Now, i have a personal project that consumes a WebService from a Financial service. This financial service uses WSE 3.0 and a Signature Certification by a CA.

      I´m using WSS4J, JBoss AS 6.1, JVM 1.6 and JBoss CXF 4.0.0CR1. The client works as expected (Request and response). But, the web service manager ask me to remove the ns1 prefix from the request.



      I've already tried in so many possible ways to remove this prefix (cxf Transformation feature, SOAPOutInterceptor, extending WSS4J class), by I'm still receiving the same Soap Fault message:

      Microsoft.web.services3.Security.Securityfault: The signature or decryption was invalid


      First I did try to use a AbstractSoapInterceptor and remove the prefix and the Namespace by doing this:


      public class CustomSOAPInterceptor extends AbstractSoapInterceptor {


                public CustomSOAPInterceptor() {






                public void handleMessage(SoapMessage message) throws Fault, SoapFault {

                          try {

                     SOAPMessage sm = message.getContent(SOAPMessage.class);

                     SOAPElement se = (SOAPElement) sm.getSOAPBody().getChildElements()



                        se = recursive(se);


                     message.setContent(SOAPMessage.class, sm);

                          } catch (org.w3c.dom.DOMException de) {



                          } catch (Exception e) {






                private SOAPElement recursive(SOAPElement element) throws SOAPException {

                   List copy = new ArrayList();

                          if (element.getAttributes().getLength() != 0) {

                                    if (element.getAttribute("xmlns:ns1") != null) {





                          if (!element.getPrefix().isEmpty()) {


                                    if (element.getPrefix().equals("ns1"))





                          try {

                                    for (Iterator iter = element.getChildElements(); iter.hasNext();) {

                                              Object obj = iter.next();

                                              if (obj instanceof SOAPElement) {

                                                        SOAPElement se = (SOAPElement) obj;

                                                        if (se.getNodeType() != SOAPElement.TEXT_NODE) {

                                                                  if (se.getChildElements().hasNext())

                                                                            se = recursive(se);


                                                        copy.add((SOAPElement) se);

                                              } else

                                                        copy.add((javax.xml.soap.Text) obj);




                                    for (Object soapElement : copy) {

                                              if (soapElement instanceof SOAPElement)

                                                        element.addChildElement((SOAPElement) soapElement);


                                                        element.appendChild((javax.xml.soap.Text) soapElement);


                          } catch (SOAPException e) {

                                    throw e;


                          return element;




      Obviusly, not works!


      Then, I change the Interceptor for a WSS4JOutInterceptor extended Class, and again I got the same soapFault message.


      Any ideas?


      Please, if anybody can help me, i'll apreciate a lot.