2014-09-02 156 views
0

我想從一大組架構(總共15k行)使用Axis2 wsdl2java生成java存根,並遇到以下複雜類型的問題。最初,當我在架構文件上運行該工具時,我收到了一個不起眼的錯誤消息,「不支持的內容簡單內容!」爲了找到這個錯誤的原因,我從源代碼下載並部署了Axis2項目,找到錯誤字符串並檢查導致問題的元素。 我認爲問題的根源在於將複雜類型與簡單內容嵌套在簡單內容中。WSDL2Java失敗 - 嵌套內容

我有兩個例子,SequencedTextType,從而未能,和OpenTextType,承受。這兩種類型的內容都是TextType的擴展。這應該可以更容易地發現問題並提供解釋。

失敗 SequencedTextType:

<xs:element name="Reason" type="SequencedTextType" id="oagis-id-fa892eb1e28c46088bc50394c62a8655"/> 

<xs:complexType name="SequencedTextType" id="oagis-id-51e010d7a1e24ebe89fcf58989fefd1b"> 
    <xs:complexContent> 
     <xs:extension base="TextType"> 
      <xs:attribute name="sequenceNumber" type="NumberType_B98233" id="oagis-id-39a5a53826024a65a2291f50d9feecd3"/> 
     </xs:extension> 
    </xs:complexContent> 
</xs:complexType> 

<xs:simpleType name="NumberType_B98233" id="oagis-id-d614ed8726ff482c9c5a8183d735d9ed"> 
    <xs:restriction base="xs:integer"/> 
</xs:simpleType> 

傳遞 OpenTextType:

<xs:complexType name="OpenTextType" id="oagis-id-5840f7a57dd949ababcd1eb394b2840c"> 
    <xs:simpleContent> 
     <xs:extension base="TextType"> 
      <xs:attribute name="typeCode" type="CodeType_1E7368" id="oagis-id-2780e69800934662a4782be31c2bacf6" 
          use="optional"/> 
     </xs:extension> 
    </xs:simpleContent> 
</xs:complexType> 

<xs:simpleType name="CodeType_1E7368" id="oagis-id-d2f721a297684b538e7dbb88cf5526bc"> 
    <xs:restriction base="xs:token"/> 
</xs:simpleType> 

共享 TextType:

<xs:complexType name="TextType" id="oagis-id-d97b8cf6a26f408db148163485796d15"> 
    <xs:simpleContent> 
     <xs:extension base="TextType_62S0B4"/> 
    </xs:simpleContent> 
</xs:complexType> 

<xs:complexType name="TextType_62S0B4" id="oagis-id-89be97039be04d6f9cfda107d75926b4"> 
    <xs:simpleContent> 
     <xs:extension base="xs:string"> 
      <xs:attribute name="languageCode" type="clm56392A20081107_LanguageCodeContentType" id="oagis-id-c8d0c7094d7d4fbeb7e50fd20a17c1b3" use="optional"/> 
     </xs:extension> 
    </xs:simpleContent> 
</xs:complexType> 

<xs:simpleType name="clm56392A20081107_LanguageCodeContentType" id="oagis-id-c5e8ac8c44894e54a147a870136da686"> 
    <xs:restriction base="xs:normalizedString"/> 
</xs:simpleType> 

Axis2的方法:

private void copyMetaInfoHierarchy(BeanWriterMetaInfoHolder metaInfHolder, 
            QName baseTypeName, 
            XmlSchema parentSchema) 
     throws SchemaCompilationException { 

    //... Code omitted for clarity 

    // see whether this type is also extended from some other type first 
    // if so proceed to set their parents as well. 
    if (type instanceof XmlSchemaComplexType) { 
     XmlSchemaComplexType complexType = (XmlSchemaComplexType) type; 
     if (complexType.getContentModel() != null) { 
      XmlSchemaContentModel content = complexType.getContentModel(); 
      if (content instanceof XmlSchemaComplexContent) { 
       //continue recursion 
      } else if (content instanceof XmlSchemaSimpleContent) { 
       /***** TextType throws error in this branch *****/ 
       throw new SchemaCompilationException(
         SchemaCompilerMessages.getMessage("schema.unsupportedcontenterror", "Simple Content")); 
      } else { 
       throw new SchemaCompilationException(
         SchemaCompilerMessages.getMessage("schema.unknowncontenterror")); 
      } 
     } 
     //Do the actual parent setting 
     metaInfHolder.setAsParent(baseMetaInfoHolder); 
    } 
    //... Code omitted for clarity 
} 

這裏是相關的錯誤信息:org.apache.axis2.schema.SchemaCompilationException:

所致不支持的內容簡單的內容! at org.apache.axis2.schema.SchemaCompiler.copyMetaInfoHierarchy(SchemaCompiler.java:1396) at org.apache.axis2.schema.SchemaCompiler.processComplexContent(SchemaCompiler.java:1279) at org.apache.axis2.schema。 SchemaCompiler.processContentModel(SchemaCompiler.java:1228) at org.apache.axis2.schema.SchemaCompiler.processComplexType(SchemaCompiler.java:1172) at org.apache.axis2.schema.SchemaCompiler.processNamedComplexSchemaType(SchemaCompiler.java:1092) at org.apache.axis2.schema.SchemaCompiler.processSchema(SchemaCompiler.java:1006) at org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.java:772) at org.apache.axis2.schema。 SchemaCompiler.processElement(SchemaCompiler.java:604) at org.apache .hais2.schema.SchemaCompiler.process(SchemaCompiler.java:2052) at org.apache.axis2.schema.SchemaCompiler.processParticle(SchemaCompiler.java:1935) at org.apache.axis2.schema.SchemaCompiler.processComplexContent(SchemaCompiler .java:1283) at org.apache.axis2.schema.SchemaCompiler.processContentModel(SchemaCompiler.java:1228) at org.apache.axis2.schema.SchemaCompiler.processComplexType(SchemaCompiler.java:1172) at org.apache .hais2.schema.SchemaCompiler.processNamedComplexSchemaType(SchemaCompiler.java:1092) at org.apache.axis2.schema.SchemaCompiler.processComplexContent(SchemaCompiler.java:1261) at org.apache.axis2.schema.SchemaCompiler.processContentModel(SchemaCompiler .java:1228) at org.apache.axis2.schema.SchemaCompiler.processComplex鍵入(SchemaCompiler.java:1172) at org.apache.axis2.schema.SchemaCompiler.processNamedComplexSchemaType(SchemaCompiler.java:1092) at org.apache.axis2.schema.SchemaCompiler。processSchema(SchemaCompiler.java:1006) at org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.java:645) at org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.java:615) at org.apache.axis2.schema.SchemaCompiler.compile(SchemaCompiler.java:423) at org.apache.axis2.schema.SchemaCompiler.compile(SchemaCompiler.java:292) at org.apache.axis2.schema.ExtensionUtility。 invoke(ExtensionUtility.java:102)

我希望深入瞭解爲什麼OpenTextType可以通過附加的Axis2方法並且爲什麼SequencedTextType不能。謝謝。

+0

你是怎麼解決這個問題的。 – subbu 2015-02-17 15:08:11

回答

3

我不確定爲什麼會發生這種情況。 但是,我發現解決方案從this link

它的工作對我來說,當我加-d xmlbeans同時使用wsdl2java命令

默認綁定是亞行和它與這個簡單的內容有些問題。 看來這已在Axis2 1.7.x版本中修復。