title: JAX-WS Force use of xmlns prefix in SOAP request?
body: <p>I have a ASP.NET 2.0 webservice that is being invoked from JAX-WS 2.1.  If I test with SOAP UI it works.  SOAP UI generates a request of the form</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sup="abc.123"&gt;
     &lt;soapenv:Header/&gt;
     &lt;soapenv:Body&gt;
        &lt;sup:Method&gt;
           &lt;sup:element&gt;GBA&lt;/sup:element&gt;
           &lt;sup:attributes&gt;
              &lt;sup:Attribute&gt;
                 &lt;sup:attributeName&gt;XYZ&lt;/sup:attributeName&gt;
                 &lt;sup:attributeValue&gt;123&lt;/sup:attributeValue&gt;
              &lt;/sup:Attribute&gt;
           &lt;/sup:attributes&gt;
           &lt;sup:nop&gt;abc&lt;/sup:nop&gt;
           &lt;sup:data&gt;1&lt;/sup:data&gt;
        &lt;/sup:Method&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>This works correctly, and the web service receives and correctly processes the data.  However the JAX-WS client creates a request of the form</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
    &lt;soapenv:Body&gt;
      &lt;Method xmlns="abc.123"&gt;
        &lt;element&gt;
          &lt;name&gt;GBA&lt;/name&gt;
        &lt;/element&gt;
        &lt;attributes&gt;
          &lt;Attribute&gt;
            &lt;attributeName&gt;XYZ&lt;/attributeName&gt;
            &lt;attributeValue&gt;123&lt;/attributeValue&gt;
          &lt;/Attribute&gt;
        &lt;/attributes&gt;
        &lt;nop&gt;abc&lt;/nop&gt;
        &lt;data&gt;1&lt;/data&gt;
      &lt;/Method&gt;
    &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>This does not work correctly.  The ASP.NET webservice interprets all the parameters <em>except</em> <code>element</code> as <code>null</code>.  Obviously this causes processing to fail.  A message is returned and correctly interpreted by the JAX-WS proxy. </p>
  
  <p><strong>How can I force JAX-WS (either in the client generation or in the code) to use the namespace prefix?</strong>  Alternatively is there a way to tell ASP.NET how to interpret the SOAP message as is?</p>
  
  <hr>
  
  <p>So far I've read up on JAX-WS and it seams to have plenty of options for customizing the java created, but I haven't found any parameters or binding rules for customizing how it creates the SOAP.</p>
  
  <p>The only thing I have found that looks promising is using a <a href="http://download.oracle.com/javase/6/docs/api/javax/xml/ws/handler/soap/SOAPHandler.html" rel="nofollow noreferrer"><code>SoapHandler</code></a> to manually edit the xml construct, as was suggested in <a href="https://stackoverflow.com/questions/3846121/changing-the-default-xml-namespace-prefix-generated-with-jaxws/4782059#4782059">this answer</a>.  However this involves writing code to walk the DOM and prepend the prefix to each node.  I haven't successfully tested this option yet ...</p>