title: Customizing Java packages JAXB wsimport
body: <p>I'm trying to generate a client with maven and jaxb from a wsdl file with 2 schemas inside and some elements with the same name from different schemas</p>
  
  <p>When I try to execute the compilation I'm getting the next error:</p>
  
  <pre><code>Two declarations cause a collision in the ObjectFactory class.
  </code></pre>
  
  <p><strong>WSDL schemas</strong>:</p>
  
  <pre><code>&lt;wsdl:types&gt;
      &lt;schema targetNamespace="http://ws.services" xmlns="http://www.w3.org/2001/XMLSchema"&gt;...&lt;/schema&gt;
      &lt;schema targetNamespace="http://ws.models" xmlns="http://www.w3.org/2001/XMLSchema"&gt;...&lt;/schema&gt;
  &lt;/wsdl:types&gt;
  </code></pre>
  
  <p>I tried renaming the elements that produce the error, but <strong>then my spring client receive the correct SOAP message, but it doesn't populate the response object properly (all its attributes are null)</strong>. I guess the problem might come from renaming the response classes, so that's why I'm trying to generate different packages keeping the original name of all the classes.</p>
  
  <p>In order to do that, I wrote the next bindings file but I don't know what I'm doing wrong that it is not working.</p>
  
  <p><strong>bindings.xml</strong> file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;  
  &lt;jaxb:bindings version="2.1"  
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"  
      xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"  
      xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"  
      xmlns:xs="http://www.w3.org/2001/XMLSchema" &gt;  
  
  &lt;jaxb:bindings schemaLocation="mywsdl.wsdl#types?schema1"
      node="/xs:schema[@targetNamespace='http://ws.services']"&gt;  
          &lt;jaxb:schemaBindings&gt;  
              &lt;jaxb:package name="package1" /&gt;  
          &lt;/jaxb:schemaBindings&gt;  
  &lt;/jaxb:bindings&gt;  
  
  &lt;jaxb:bindings schemaLocation="mywsdl.wsdl#types?schema2"
      node="/xs:schema[@targetNamespace='http://ws.models']"&gt;  
          &lt;jaxb:schemaBindings&gt;  
              &lt;jaxb:package name="package2" /&gt;  
          &lt;/jaxb:schemaBindings&gt;  
  &lt;/jaxb:bindings&gt; 
  
  &lt;/jaxb:bindings&gt;  
  </code></pre>
  
  <p>My configuration part in the maven file is the next, just in case it is useful:</p>
  
  <pre><code>&lt;groupId&gt;org.jvnet.jax-ws-commons&lt;/groupId&gt;
  &lt;artifactId&gt;jaxws-maven-plugin&lt;/artifactId&gt;
  &lt;version&gt;2.3&lt;/version&gt;
  &lt;executions&gt;
      &lt;execution&gt;
          &lt;goals&gt;
              &lt;goal&gt;wsimport&lt;/goal&gt;
          &lt;/goals&gt;
      &lt;/execution&gt;
  &lt;/executions&gt;
  &lt;configuration&gt;
      &lt;wsdlLocation&gt;wsdl/mywsdl.wsdl&lt;/wsdlLocation&gt;
      &lt;wsdlDirectory&gt;src/main/resources/wsdl&lt;/wsdlDirectory&gt;
      &lt;wsdlFiles&gt;
          &lt;wsdlFile&gt;mywsdl.wsdl&lt;/wsdlFile&gt;
      &lt;/wsdlFiles&gt;
      &lt;bindingDirectory&gt;src/main/resources/wsdl&lt;/bindingDirectory&gt;
      &lt;bindingFiles&gt;
          &lt;bindingFile&gt;bindings.xml&lt;/bindingFile&gt;
      &lt;/bindingFiles&gt;
      &lt;packageName&gt;original.package&lt;/packageName&gt;
      &lt;sourceDestDir&gt;${basedir}/src/main/java&lt;/sourceDestDir&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>When I compile with this bindings files, the same error appears. So I think that maybe it isn't right.</p>
  
  <p>Do you find any mistakes?</p>
  
  <p>Thanks.</p>