title: Spring 4, SOAP WS, XSD... Producing two different WSDL
body: <p>second time I'm trying to ask this without any answer, though i don't think this should be an hard question for a good Spring developer..</p>
  
  <p><strong>I want to create a simple Spring 4 (Annotation driven) Application, this will use the maven-jaxb-plugin to generate every request response object factory and object mapping classes...</strong></p>
  
  <p>I want this application to produce 2 WSDL, so as my assumption, i started from two different XSD, and with two different SPRING WsConfigurerAdapter classes that configure both WSDL, and obviously, two different classes to manage Endpoints..</p>
  
  <p>Everything work... But my question is:</p>
  
  <blockquote>
    <p>I ve a bean shared between the two WSDL, and consequently between the two XSD, how to accomplish this? XSD and Maven Plugin side, everything keep working as well if i declare a complex type inside an XSD and than import or include it into the second one, but SPRING 4 side, when i just add the import and the bean, the WSDL with the import has not been resolved, something like unexpected end of file, it's obvious that i'm missing or making something wrong... but what?</p>
  </blockquote>
  
  <p>The first XSD where the shared entity is declared..</p>
  
  <pre><code>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:usr="http://concretepage.com/soap/userManagement" targetNamespace="http://concretepage.com/soap/userManagement"&gt;
  
      &lt;xs:element name="getUserRequest"&gt;
          &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                  &lt;xs:element name="userId" type="xs:int" /&gt;
              &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
      &lt;xs:element name="getUserResponse"&gt;
          &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                  &lt;xs:element name="user" type="usr:user" /&gt;
              &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;  
  
      &lt;!-- share bean --&gt;
      &lt;xs:complexType name="user"&gt;
          &lt;xs:sequence&gt;
              &lt;xs:element name="userId" type="xs:int" /&gt;
              &lt;xs:element name="userName" type="xs:string" /&gt;
              &lt;xs:element name="age" type="xs:int" /&gt;
              &lt;xs:element name="password" type="xs:string" /&gt;
              &lt;xs:element name="passwordffd" type="xs:string" /&gt;
          &lt;/xs:sequence&gt;
      &lt;/xs:complexType&gt;
  
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>The second XSD, now the import is commented and everything works like this, but without the element User injected into the Job, if i enable it with the import, the jobManagement WSDL SOAP-UI load fails:</p>
  
  <pre><code>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:tns="http://concretepage.com/soap/jobManagement" targetNamespace="http://concretepage.com/soap/jobManagement"
      xmlns:usr="http://concretepage.com/soap/userManagement"&gt;
      &lt;!-- import --&gt;
      &lt;!-- xs:import schemaLocation="userManagement.xsd"
          namespace="http://concretepage.com/soap/userManagement" / --&gt;
  
      &lt;xs:element name="getJobRequest"&gt;
          &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                  &lt;xs:element name="jobId" type="xs:int" /&gt;
              &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
      &lt;xs:element name="getJobResponse"&gt;
          &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                  &lt;xs:element name="job" type="tns:job" /&gt;
              &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
  
      &lt;xs:complexType name="job"&gt;
          &lt;xs:sequence&gt;
              &lt;xs:element name="jobId" type="xs:int" /&gt;
              &lt;xs:element name="jobName" type="xs:string" /&gt;
              &lt;xs:element name="jobRole" type="xs:string" /&gt;
              &lt;xs:element name="salary" type="xs:int" /&gt;
              **&lt;!--  xs:element name="user" type="usr:user" /--&gt;**
          &lt;/xs:sequence&gt;
      &lt;/xs:complexType&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>This is the Spring class to generate the WSDL that has the shared bean:</p>
  
  <pre><code>@Configuration
  @EnableWs
  @ComponentScan("com.concretepage")
  public class JobConfig extends WsConfigurerAdapter {
  
      @Bean(name = "jobManagement")
      public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema jobSchema) {
          DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
          wsdl11Definition.setPortTypeName("jobManagementPort");
          wsdl11Definition.setLocationUri("/soapws/jobManagement/");
          wsdl11Definition.setTargetNamespace("http://localhost:8080/spring4soap/");
          wsdl11Definition.setSchema(jobSchema);
  
          return wsdl11Definition;
      }
  
      @Bean
      public XsdSchema jobSchema() {
          return new SimpleXsdSchema(new ClassPathResource("jobManagement.xsd"));
      }
  }
  </code></pre>