title: How to remove prefix and namespace in SOAPElement?
body: <p>Collogues, i have cycle which create soap xml with nessesary structure (don't ask about the structure) </p>
  
  <pre><code>log.info("Body elements: ");
  NodeList nodeList = body.getElementsByTagName("*") ;
  for (int i = 0; i &lt; 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("");
          }
      }
  }
  </code></pre>
  
  <p>As a result I receive xml:</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
     &lt;soapenv:Body&gt;
        &lt;ns3:request xmlns:ns3="http://mayacomp/Generic/Ws"&gt;
           &lt;in xmlns="http://mayacomp/Generic/Ws"&gt;
              &lt;requestHeader&gt;
  </code></pre>
  
  <p>My question is how to remove only <code>xmlns="http://mayacomp/Generic/Ws"</code> from  <code>&lt;in&gt;</code> element and receive:</p>
  
  <pre><code>   &lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
         &lt;soapenv:Body&gt;
            &lt;ns3:request xmlns:ns3="http://mayacomp/Generic/Ws"&gt;
               &lt;in&gt;
                  &lt;requestHeader&gt;
  </code></pre>
  
  <p><strong>UPDATE</strong> </p>
  
  <p>I tried to config xml element:</p>
  
  <pre><code>    /*Config body elements*/
                  while (itBodyElements.hasNext()) 
                  {  
                    Object o = itBodyElements.next();
                    SOAPBodyElement bodyElement = (SOAPBodyElement) o;
                    log.info("Elements from 'Body' element = " + bodyElement.getLocalName() );
  
                    Iterator it2 = bodyElement.getChildElements();
                           while (it2.hasNext()) 
                           { 
                                Object requestElement = it2.next();
                                SOAPBodyElement bodyRequest = (SOAPBodyElement) requestElement;
                                log.info("  Elements from '"+ bodyElement.getLocalName() + "' element = " + bodyRequest.getLocalName()); 
                                log.info("  Delete namespace from IN element " + bodyRequest.getLocalName());
                                bodyRequest.removeNamespaceDeclaration(bodyRequest.getPrefix());
                                bodyRequest.setPrefix("");
  
                                 Iterator it3 = bodyRequest.getChildElements();
                                      while (it3.hasNext())
                                      { //work with other elements
  </code></pre>
  
  <p>But it has not effect to 'in' element. After run i still have:
  <code>&lt;in xmlns="http://mayacomp/Generic/Ws"&gt;</code></p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I solved the problem by calling ws as next:</p>
  
  <pre><code>getWebServiceTemplate().marshalSendAndReceive(
                  "URL",
                  request,
                  new WebServiceMessageCallback()
                  { public void doWithMessage(WebServiceMessage message) {
  
                          SaajSoapMessage saajSoapMessage = (SaajSoapMessage)message;
  
                          SOAPMessage soapMessage = UtilsClass.createSOAPMessage(in);
  
                          saajSoapMessage.setSaajMessage(soapMessage);
  
                  }
  
                  } 
                  );
  </code></pre>
  
  <p>Method <strong>createSOAPMessage</strong> configure soap message using javax.xml.soap library.</p>