title: JAX WS, JAXB and Null elements with attributes
body: <p>I am trying to consume a web service using JAXWS and wsimport. The WSIMPORT tool generated all the required classes and I can invoke the service without any issues. </p>
  
  <p>However, I noticed in cases where response contains a nil element with valid attribute values, JAXWS fails to unmarshall it and throws a NullPointerException. I used SOAP UI to help debug and here's what I found. The response returns the following XML (Excerpt):</p>
  
  <pre><code>            &lt;externalIdentifiers&gt;
                   &lt;identifierType code="2" name="Passport" xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/&gt;
                   &lt;identifierValue/&gt;
                   &lt;issuingCountry xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/&gt;
                &lt;/externalIdentifiers&gt;
  </code></pre>
  
  <p>In my Java code, when trying to read the "name" property of identifier type as above, it throws a NPE:</p>
  
  <pre><code>      if(id.getIdentifierType() == null)
              {
                  System.out.println("NULL");
              }
              System.out.println("Identifier Type: " + id.getIdentifierType().getName());
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>NULL
  Exception in thread "main" java.lang.NullPointerException
  </code></pre>
  
  <p>To me that does looks a reasonable response as in the response, identifierType is set as xsi:nil="true". That is also perfectly valid XML as per W3C. Question is, how do I read the attribute values such as code and name in such a case?</p>