2013-05-15 46 views
1

我想從WSDL生成Java類。我從一個ant任務中調用wsdl2java。命令行應該是這樣的:axis2無法通過內聯模式從wsdl生成java

java -cp ... org.apache.axis2.wsdl.WSDL2Java -o generated_dir -S . -R . -l java -p "com.make.me.rich" -d adb -or --noBuildXML -uri MakeMeRich.wsdl 

的MakeMeRich.wsdl包含Micrsosoft內聯模式,例如:

<xsd:schema elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> 
    <xsd:complexType name="ArrayOfint"> 
    <xsd:sequence> 
     <xsd:element minOccurs="0" maxOccurs="unbounded" name="int" type="xsd:int" /> 
    </xsd:sequence> 
    </xsd:complexType> 
    <xsd:element name="ArrayOfint" nillable="true" type="tns:ArrayOfint" /> 
    <xsd:complexType name="ArrayOfKeyValueOfstringstring"> 
     <xsd:annotation> 
     <xsd:appinfo> 
      <IsDictionary xmlns="http://schemas.microsoft.com/2003/10/Serialization/">true</IsDictionary> 
     </xsd:appinfo> 
     </xsd:annotation> 
     <xsd:sequence> 
     <xsd:element minOccurs="0" maxOccurs="unbounded" name="KeyValueOfstringstring"> 
      <xsd:complexType> 
      <xsd:sequence> 
       <xsd:element name="Key" nillable="true" type="xsd:string" /> 
       <xsd:element name="Value" nillable="true" type="xsd:string" /> 
      </xsd:sequence> 
      </xsd:complexType> 
     </xsd:element> 
     </xsd:sequence> 
    </xsd:complexType> 
    <xsd:element name="ArrayOfKeyValueOfstringstring" nillable="true" type="tns:ArrayOfKeyValueOfstringstring" /> 
</xsd:schema> 

但WSDL2Java的解析器發出警告:

[java] Warning: No schemaLocation for import of http://schemas.microsoft.com/2003/10/Serialization/Arrays; compilation may fail 

任何想法如何使用wsdl2java處理內聯模式?

回答

1

使用數據綁定xmlbeans似乎解決了問題:-d xmlbeans

0

將它作爲wsdl中的內聯模式。

+0

感謝Ratha的提示。當我在建議內聯模式的WSDL時仔細觀察WSDL時,發現WSDL實際上已經使用了內聯模式。所以看起來wsdl2java並不像我這樣調用時正確處理內聯模式。 – Martin

0

您正在使用哪個版本的Axis2?我在版本1.6.x中遇到了類似的問題,而在1.5.x及更低版本中,一切正常。你能用舊版本試試嗎? 在我看來,使用xmlbeans不是一個解決方案,它只是一個解決方法。

+0

我正在使用Axis2 1.6.2。 Axis2項目頁面指出,ADB「絕不意圖成爲像XMLBeans這樣的功能齊全的模式編譯器。」 ([ADB HowTo](http://axis.apache.org/axis2/java/core/docs/adb/adb-howto.html))。所以我明白,你不能指望任何WSDL構造與ADB一起工作。 – Martin