2009-09-18 152 views
1

Web服務WSDL包含下面的模式:JAXB:元件類型來命名,而不是屬性

<xs:complexType name="DocumentSearchInfo"> 
    <xs:sequence> 
    ... 
     <xs:element minOccurs="0" name="Industries" nillable="true" type="tns:ListCondition"> 
     <xs:annotation> 
      <xs:appinfo> 
      <DefaultValue EmitDefaultValue="false" xmlns="http://schemas.microsoft.com/2003/10/Serialization/" /> 
      </xs:appinfo> 
     </xs:annotation> 
     </xs:element> 
    ... 
    </xs:sequence> 
    </xs:complexType> 

通過加入在NetBeans 6.7 web引用生成此代碼:

@XmlAccessorType(XmlAccessType.FIELD) 
@XmlType(name = "DocumentSearchInfo", propOrder = { 
    "analysts", 
    "companyIDCondition", 
    "contributorCondition", 
    "countries", 
    "dateRange", 
    "documentIDCondition", 
    "documentPageCondition", 
    "industries", 
    "keywordCondition", 
    "languages", 
    "profileID", 
    "purchasedOnly", 
    "regions", 
    "researchCategories", 
    "researchProduct" 
}) 

    public class DocumentSearchInfo { 
    ... 
     @XmlElementRef(name = "Industries", namespace = "http://somenshere", type = JAXBElement.class) 
     protected JAXBElement<ListCondition> industries; 
    ... 
    } 

,其在它被序列化爲

<ns2:SearchInfo> 
... 
    <ns2:ListCondition> 
    <ns2:Values> 
     <ns3:string>1385</ns3:string> 
     <ns3:string>1386</ns3:string> 
    </ns2:Values> 
    </ns2:ListCondition> 
... 
</ns2:SearchInfo> 

我希望在此XML中看到'行業',而不是'ListCondition'。

我沒有問題使用.net的服務:svcutil和wsdl.exe都可以正常工作,無論使用什麼序列化器,但看起來我完全錯過了Java中序列化的一些明顯的東西。

任何人都可以幫忙嗎?

回答

1

已解決。我應該調用ObjectFactory的createDocumentSearchInfoIndustries方法。與我曾經使用過的.net不同)

相關問題