0

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

4

1 に答える 1

2

ベンダーによる少なくとも非常に悪い wsdl 設計 (特に、会社名に「標準」という単語が含まれているもの): グローバルな型/要素定義は一度作成し、別のグローバル XSD ファイル (のような) に入れる必要があります。彼らはここでした:

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

)。

また、サービスのバージョン管理に関する柔軟性が得られるように、サービスの名前空間をサービス固有に保つ必要があります。

この実際のコンスタレーション (同じ名前空間 + wsdls 内の要素宣言の重複) は灰色の領域のトピックであると思います.ネット上でこれに関する明確な声明を見つけられなかったので、唯一の解決策は完全に分離された両方の wsdl ファイルに対して開発することかもしれません. 1 つの共有アプリケーションではなく、axis2-wise 2 アプリケーション (wsdl ごとに 1 つ) を意味します。

于 2012-10-22T13:15:51.523 に答える