title: Why does wsimport have trouble with server object having @XmlRootElement annotation?
body: <p>I was completing work on a web service using JAX-WS on the server side. In many of the domain objects I used <code>@XmlRootElement</code> to help facilitate the unmarshaling of XML files into the service using JAXB. All went well and the output was what I expected to see using SoapUI.</p>
  
  <p>However, when I used wsimport to create the client (as a convenience DAO for other developers), I started encountering NullPointerExceptions in my client integration-test class.</p>
  
  <p>The call to the webservice worked correctly, and a response was received by the client, but my more-complex objects were null. Simple attributes, like Strings, were returning full of usable data, but not the larger objects.</p>
  
  <p>Through iterations of recreating services using simple Strings and migrating to more complex objects, I discovered that when the client received objects that were declared on the server with <code>@XmlRootElement</code>, these were the objects that were null. If the server object did not have the <code>@XmlRootElement</code> annotation, the client received all of the data in all of its complex glory.</p>
  
  <p>Initially the lack of <code>@XmlRootElement</code> gave me fits with unmarshaling the data on the server, but <a href="https://stackoverflow.com/a/6998627/197496">this answer</a> helped me out.</p>
  
  <p>So, the phenomenon of the wsimport client silently failing on the unmarshaling of the web service response because of the <code>@XmlRootElement</code> annotation (on the server!) has me concerned. In this case I had control of both sides and could do something about it. But, what if I don't have control of the server? How would I have resolved this with just the wsimport-generated code? </p>