title: How to unmarshall SOAP response using JAXB if namespace declaration is on SOAP envelope?
body: <p>JAXB can only unmarshall an XML if the soap envelope has already been removed. However, the SOAP response I'm trying to unmarshall has its namespace declaration on the soap envelope. If I remove the soap envelope, the namespace declaration will also be removed. As such the prefix of the tags will be referring to none. This causes JAXB to throw an error. How can I unmarshall a SOAP response using JAXB if the namespace is declared on the SOAP envelope?</p>
  
  <p>A similar sample of the XML that I need to unmarshall is below:</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://example.com/"&gt;
      &lt;soapenv:Body&gt;
          &lt;ns:getNumberResponse&gt;
              &lt;number&gt;123456789&lt;/number&gt;
          &lt;/ns:getNumberResponse&gt;
      &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>This is what happens if I remove the soap envelope:</p>
  
  <pre><code>&lt;ns:getNumberResponse&gt;
      &lt;number&gt;123456789&lt;/number&gt;
  &lt;/ns:getNumberResponse&gt;
  </code></pre>
  
  <p>If I removed the soap envelope, the namespace declaration will also be gone. JAXB won't be able to unmarshall the above xml because the namespace definition for the prefix "ns" is missing. As such it will return a <code>"The prefix "ns" for element "ns:getNumberResponse" is not bound."</code> error message. How do I fix it?</p>
  
  <p>Please note that I'm using JDK 1.5. I'm not sure if there is a way to solve this in JDK 1.6. I was able to use JAXB because I downloaded the required jars for using JAXB.</p>