title: JAXB Bindings in embedded XSD
body: <p>I have a <code>wsdl</code> with an embedded <code>xsd</code>.</p>
  
  <pre><code>&lt;wsdl:definitions name="AcmeService"
      targetNamespace="http://www.acme.com/services/Acme/WcfService"
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
      xmlns:tns="http://www.acme.com/services/Acme/WcfService"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
      &lt;wsdl:types&gt;
          &lt;xsd:schema targetNamespace="http://www.acme.com/services/Acme/WcfService/Imports"&gt;
              &lt;xsd:import schemaLocation="http://services01.acme.com/WebServices/AcmeWcfClient/service/AcmeService.svc?xsd=xsd0" namespace="http://www.acme.com/services/Acme/WcfService" /&gt;
              &lt;xsd:import schemaLocation="http://services01.acme.com/WebServices/AcmeWcfClient/service/AcmeService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" /&gt;
          &lt;/xsd:schema&gt;
      &lt;/wsdl:types&gt;
      &lt;!-- Some more WSDL Content --&gt;
  &lt;/wsdl:definitions&gt;
  </code></pre>
  
  <p>My 'xsd' contains the following definitions:</p>
  
  <pre><code>&lt;xs:schema elementFormDefault="qualified" targetNamespace="http://www.acme.com/services/Acme/WcfService"&gt;
      &lt;xs:element name="SetApplication"&gt;
          &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                  &lt;xs:element minOccurs="0" name="application" nillable="true" type="tns:Application"/&gt;
              &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
      &lt;xs:complexType name="Application"&gt;
          &lt;xs:sequence&gt;
              &lt;xs:element minOccurs="0" name="SomeElement" nillable="true" type="xs:string"/&gt;
              &lt;xs:element minOccurs="0" name="AnotherElement" nillable="true" type="xs:string"/&gt;
              &lt;xs:element minOccurs="0" name="AcmeDetails" nillable="true" type="tns:Acme"/&gt;
          &lt;/xs:sequence&gt;
      &lt;/xs:complexType&gt;
      &lt;xs:element name="Application" nillable="true" type="tns:Application"/&gt;
      &lt;xs:complexType name="Acme"&gt;
          &lt;xs:sequence&gt;
              &lt;xs:element minOccurs="0" name="PropertyOne" nillable="true" type="xs:string"/&gt;
              &lt;xs:element minOccurs="0" name="PropertyTwo" nillable="true" type="xs:string"/&gt;
          &lt;/xs:sequence&gt;
      &lt;/xs:complexType&gt;
      &lt;xs:element name="Acme" nillable="true" type="tns:Acme"/&gt;
      &lt;xs:element name="GetAcmeDetails"&gt;
          &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                  &lt;xs:element minOccurs="0" name="acme" nillable="true" type="tns:Acme"/&gt; &lt;!-- "acme" name is lowercase on purpose --&gt;
              &lt;/xs:sequence&gt;
         &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
      &lt;xs:element name="GetAcmeDetailsResponse"&gt;
          &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                  &lt;xs:element minOccurs="0" name="GetAcmeDetailsResult" nillable="true" type="tns:Acme"/&gt;
              &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>My problem comes from the fact that, when generating the service stubs using wsimport, I am left with the following definition for <code>Acme</code>:</p>
  
  <pre><code>@XmlType(name = "Acme", namespace = "http://www.acme.com/services/Acme/WcfService", propOrder = {
  </code></pre>
  
  <p>The issue being that I need both <code>Acme</code> and <code>AcmeDetails</code> to resolve to the same underlying <code>Acme</code> object.</p>
  
  <p>Looking at a couple of other, similar, questions (<a href="https://stackoverflow.com/questions/6214576/jax-ws-import-and-customizing-package-to-namespace-mapping">here</a>, <a href="https://stackoverflow.com/questions/5484345/combine-jaxb-and-jaxws-for-an-imported-xml-schema">here</a>, and <a href="https://stackoverflow.com/questions/6845989/jaxb-empty-node-in-bindings">here</a>) I have tried to create a binding using the following XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;jaxws:bindings
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.1"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    wsdlLocation="Acme_Service.wsdl"&gt;
      &lt;enableWrapperStyle&gt;true&lt;/enableWrapperStyle&gt;
      &lt;enableAsyncMapping&gt;false&lt;/enableAsyncMapping&gt;
      &lt;jaxws:bindings node="wsdl:definitions/wsdl:types/xs:schema/xs:complexType[@name='Application']/xs:sequence/xs:element[@name='AcmeDetails']"&gt;
          &lt;jaxb:class name="AcmeDetails"/&gt;
      &lt;/jaxws:bindings&gt;
  &lt;/jaxws:bindings&gt;
  </code></pre>
  
  <p>The above binding generates the class 'AcmeDetails' but the XMLType Annotation remains 'Acme'.</p>
  
  <p>Any help in generating bindings to both <code>Acme</code> and <code>AcmeDetails</code> in the above extract greatly appreciated.</p>