title: Marshalling using ComplexType name instead of JAXB class name annotation
body: <p>I'm trying to consume a REST WebService, in which requests are sent as serialized XML objects</p>
  
  <p>Here is an example</p>
  
  <pre><code>https://localhost:9985/fr_FR/api.ReceiveXMLmessage?xmlString=&lt;TDetails_XCC OpeType="SOME_OPERATION"&gt;&lt;TeamID&gt;SOME_ID&lt;/TeamID&gt;&lt;/TDetails_XCC&gt;
  </code></pre>
  
  <p>From this, I created the following XSD schema</p>
  
  <pre><code>&lt;complexType name="TDetails_XCC"&gt;
      &lt;annotation&gt;
          &lt;appinfo&gt;
              &lt;jaxb:class name="TeamDetailsRequestType"/&gt;
          &lt;/appinfo&gt;
          &lt;documentation&gt;Request team details&lt;/documentation&gt;
      &lt;/annotation&gt;
      &lt;complexContent&gt;
          &lt;extension base="local:SimpleRESTRequestType"/&gt;
      &lt;/complexContent&gt;
  &lt;/complexType&gt;
  
  &lt;complexType name="SimpleRESTRequestType"&gt;
      &lt;sequence&gt;
          &lt;element name="TeamID" minOccurs="0" type="long"&gt;
              &lt;annotation&gt;
                  &lt;appinfo&gt;
                      &lt;jaxb:property name="teamId"/&gt;
                  &lt;/appinfo&gt;
              &lt;/annotation&gt;
          &lt;/element&gt;
      &lt;/sequence&gt;
      &lt;attribute name="OpeType" type="string" default="some_operation"&gt;
          &lt;annotation&gt;
              &lt;appinfo&gt;
                  &lt;jaxb:property name="operationType"/&gt;
              &lt;/appinfo&gt;
          &lt;/annotation&gt;
      &lt;/attribute&gt;
  &lt;/complexType&gt;
  </code></pre>
  
  <p>This is the generated Java bean</p>
  
  <pre><code>@XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "TDetails_XCC")
  @XmlRootElement public class TeamDetailsRequestType
      extends SimpleRESTRequestType
      implements Serializable
      {
      }
  </code></pre>
  
  <p>This is the code used to serialize the bean to XML</p>
  
  <pre><code>  TeamDetailsRequestType request = new TeamDetailsRequestType();
    request.setTeamId(546464L);
    request.setOperationType("SomeOperation");
    StringWriter writer = new StringWriter();
    JAXBContext context = JAXBContext.newInstance("com.mycompany.myproject.message.team");
    Marshaller marshaller = context.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
    marshaller.marshal(request, writer);
    System.out.println(writer.toString());
  </code></pre>
  
  <p>This is what the marshalled bean looks like</p>
  
  <pre><code>&lt;teamDetailsRequestType OpeType="SomeOperation"&gt;
      &lt;TeamID&gt;546464&lt;/TeamID&gt;
  &lt;/teamDetailsRequestType&gt;
  </code></pre>
  
  <p>And this what I wished I got</p>
  
  <pre><code>&lt;TDetails_XCC OpeType="SomeOperation"&gt;
      &lt;TeamID&gt;546464&lt;/TeamID&gt;
  &lt;/TDetails_XCC&gt;
  </code></pre>
  
  <p>I managed to get it working by using the QName class</p>
  
  <pre><code>JAXBElement jx = new JAXBElement(new QName("TDetails_XCC"), request.getClass(), request);
  marshaller.marshal(jx, System.out);
  </code></pre>
  
  <p>But what I would like to know is if it possible to accomplish this solely from the XSD schema?</p>
  
  <p>Thank you for your time</p>
  
  <h1>Update</h1>
  
  <p>I'm guessing that the problem comes from the generated bean, because the problem is solved with the following bean</p>
  
  <pre><code>@XmlAccessorType(XmlAccessType.FIELD)
  @XmlType
  @XmlRootElement(name = "TDetails_XCC")
  public class TeamDetailsRequestType
      extends SimpleRESTRequestType
      implements Serializable
      {
      }
  </code></pre>
  
  <p>So, how can I change my XSD to make JAXB put the <strong><em>name</em></strong> property inside of <strong>@XmlRootElement</strong> instead of <strong>@XmlType</strong>?</p>
  
  <p>Thanks again</p>