Pergunta

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.

Example:

file1.wsdl => <xsd:element name="MyElementName"> 
file2.wsdl => <xsd:element name="MyElementName"> 

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.

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?

EDIT

Ok, so I found a flag that I can use different packages for the classes so now I have

com.package.MyElementName
com.package.ext.MyElementName

However, it still does not work because axis (or xmlbeans) give me the wrong class back.

Take a look at this example. I would assume that this would work but intead I get a ClassCastException

java.lang.ClassCastException: com.package.MyElementName.impl.MyElementNameDocumentImpl cannot be cast to com.package.ext.MyElementNameDocument

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());

EDIT--

Ok, I found the real examples on the web so I might as well show the real ones.

http://dtd.cobaltgroup.com/STAR/5.2.4/WSDL/Templates/

Among many others there are these two

http://dtd.cobaltgroup.com/STAR/5.2.4/WSDL/Templates/GetServiceProcessingAdvisory.wsdl http://dtd.cobaltgroup.com/STAR/5.2.4/WSDL/Templates/GetStandardCodes.wsdl

As you can see, both of them has the element ProcessMessage. Hopes this clarifies something.

 </xsd:complexType>
     <!--Global Elements used by the Bindings--><xsd:element name="ProcessMessage">
        <xsd:annotation>
           <xsd:documentation source="http://www.starstandard.org">
                Process Message Input
            </xsd:documentation>
        </xsd:annotation>
        <xsd:complexType>
           <xsd:sequence>
              <xsd:element name="payload"
 type="starws:GetServiceProcessingAdvisoryPayload" minOccurs="0"
                           maxOccurs="1"
                           form="qualified"/>
           </xsd:sequence>
        </xsd:complexType>
     </xsd:element>


 <!--Global Elements used by the Bindings--><xsd:element name="ProcessMessage">
        <xsd:annotation>
           <xsd:documentation source="http://www.starstandard.org">
                Process Message Input
            </xsd:documentation>
        </xsd:annotation>
        <xsd:complexType>
           <xsd:sequence>
              <xsd:element name="payload" type="starws:GetStandardCodesPayload" 
  minOccurs="0"
                           maxOccurs="1"
                           form="qualified"/>
           </xsd:sequence>
        </xsd:complexType>
     </xsd:element>

....

Regards /Johan

Foi útil?

Solução

At least very bad wsdl-design by the vendor (especially for one, which contains the word "standard" in its company name): Global type/element-definitions should be made once and i.e. put into a separate global XSD-file (like they did here:

 <xsd:include schemaLocation="STARWSDLDataTypes.xsd"/>

).

Also, the servicenamespace should be kept service-specific so a flexibility regarding service-versioning is given.

I fear this actual constellation (duplicate element declaration within same namespaces+wsdls) is a gray area topic - I did not find any clear statement regarding this on the net, so your only solution might be to develop against both wsdl-files completely separated. Meaning axis2-wise 2 applications (1 per wsdl) instead of one shared one.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top