title: Is it possible to manage duplicate element names with Axis2/XmlBeans
body: <p>We are using thirdparty wsdl files that we are generating java files with using axis2. Now we have a problem that there are duplicate elements in different files but with the same namespace.</p>
  
  <p>Example:</p>
  
  <pre><code>file1.wsdl =&gt; &lt;xsd:element name="MyElementName"&gt; 
  file2.wsdl =&gt; &lt;xsd:element name="MyElementName"&gt; 
  </code></pre>
  
  <p>So, the result is that the same file is generated twice from different wsdl files so only the last file generated actually exists after file generation.</p>
  
  <p>I was wondering if this really is correct or if it is a design flaw of the wsdl files?
  If not, how can I get around this problem using axis2?</p>
  
  <p>EDIT</p>
  
  <p>Ok, so I found a flag that I can use different packages for the classes so now I have </p>
  
  <pre><code>com.package.MyElementName
  com.package.ext.MyElementName
  </code></pre>
  
  <p>However, it still does not work because axis (or xmlbeans) give me the wrong class back. </p>
  
  <p>Take a look at this example. I would assume that this would work but intead I get a ClassCastException </p>
  
  <p>java.lang.ClassCastException: com.package.MyElementName.impl.MyElementNameDocumentImpl cannot be cast to com.package.ext.MyElementNameDocument</p>
  
  <pre><code>com.mypackage.ext.MyElementNameDocument doc1 =
     com.mypackage.ext.MyElementNameDocument.Factory.newInstance();
  doc1.addNewMyElementName();
  
  com.mypackage.ext.MyElementNameDocument doc2 = 
    com.mypackage.ext.MyElementNameDocument.Factory.parse(doc1.toString());
  </code></pre>
  
  <p>EDIT--</p>
  
  <p>Ok, I found the real examples on the web so I might as well show the real ones.</p>
  
  <p><a href="http://dtd.cobaltgroup.com/STAR/5.2.4/WSDL/Templates/" rel="nofollow">http://dtd.cobaltgroup.com/STAR/5.2.4/WSDL/Templates/</a></p>
  
  <p>Among many others there are these two</p>
  
  <p><a href="http://dtd.cobaltgroup.com/STAR/5.2.4/WSDL/Templates/GetServiceProcessingAdvisory.wsdl" rel="nofollow">http://dtd.cobaltgroup.com/STAR/5.2.4/WSDL/Templates/GetServiceProcessingAdvisory.wsdl</a>
  http://dtd.cobaltgroup.com/STAR/5.2.4/WSDL/Templates/GetStandardCodes.wsdl</p>
  
  <p>As you can see, both of them has the element ProcessMessage. Hopes this clarifies something.</p>
  
  <pre><code> &lt;/xsd:complexType&gt;
       &lt;!--Global Elements used by the Bindings--&gt;&lt;xsd:element name="ProcessMessage"&gt;
          &lt;xsd:annotation&gt;
             &lt;xsd:documentation source="http://www.starstandard.org"&gt;
                  Process Message Input
              &lt;/xsd:documentation&gt;
          &lt;/xsd:annotation&gt;
          &lt;xsd:complexType&gt;
             &lt;xsd:sequence&gt;
                &lt;xsd:element name="payload"
   type="starws:GetServiceProcessingAdvisoryPayload" minOccurs="0"
                             maxOccurs="1"
                             form="qualified"/&gt;
             &lt;/xsd:sequence&gt;
          &lt;/xsd:complexType&gt;
       &lt;/xsd:element&gt;
  
  
   &lt;!--Global Elements used by the Bindings--&gt;&lt;xsd:element name="ProcessMessage"&gt;
          &lt;xsd:annotation&gt;
             &lt;xsd:documentation source="http://www.starstandard.org"&gt;
                  Process Message Input
              &lt;/xsd:documentation&gt;
          &lt;/xsd:annotation&gt;
          &lt;xsd:complexType&gt;
             &lt;xsd:sequence&gt;
                &lt;xsd:element name="payload" type="starws:GetStandardCodesPayload" 
    minOccurs="0"
                             maxOccurs="1"
                             form="qualified"/&gt;
             &lt;/xsd:sequence&gt;
          &lt;/xsd:complexType&gt;
       &lt;/xsd:element&gt;
  </code></pre>
  
  <p>....</p>
  
  <p>Regards /Johan</p>