[英]JAXB xjc generates fields as a list of elements
wsdl文件的以下順序出現問題
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="allowCaseWithNewContract" type="xsd:boolean">
</xsd:element>
<xsd:choice minOccurs="0">
<xsd:element name="validationError" type="mnp:ErrorType"/>
<xsd:element name="internalError" type="mnp:ErrorType"/>
<xsd:element name="businessError" type="mnp:ErrorType"/>
<xsd:element name="externalError" type="mnp:ErrorType"/>
</xsd:choice>
</xsd:sequence>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="allowCaseWithExistingContract" type="xsd:boolean">
</xsd:element>
<xsd:choice minOccurs="0">
<xsd:element name="validationError" type="mnp:ErrorType"/>
<xsd:element name="internalError" type="mnp:ErrorType"/>
<xsd:element name="businessError" type="mnp:ErrorType"/>
<xsd:element name="externalError" type="mnp:ErrorType"/>
</xsd:choice>
</xsd:sequence>
我試圖使用jaxb綁定自定義:
<?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc">
<jxb:globalBindings>
<xjc:simple />
</jxb:globalBindings>
</jxb:bindings>
我試圖避免jaxb-xjc將我的字段生成為List<JAXBElement<?>> validationErrorsAndAllowCaseWithExistingContractsAndInternalErrors
,無論如何我都能做到這一點嗎?
我建議您盡可能簡化架構。 我將allowCaseWithNewContract
和allowCaseWithExistingContract
作為屬性包含在封閉元素中。 我猜然后,剩下的選擇將具有ErrorType
類型。
我不允許發表評論,但是我相信這個問題在這里和這里都已經得到解決-基本上,您最好的選擇是使用JAXB2簡化插件,因為JAXB會阻止您執行想要的(反序列化)操作從XML到Java前后均保持一致(即,您需要保留順序)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.