[英]CXF: Set minOccurs=0 for elements of the arrays
我們為Java服務器和.NET客戶端使用帶有Aegis映射器的CXF框架。 默認情況下,WSDL中類中的所有變量的minOccurs = 0。 我們在CXF配置中使用這樣的設置來防止它:
<bean id="aegisBean" class="org.apache.cxf.aegis.databinding.AegisDatabinding" scope="prototype">
<property name="configuration">
<bean class="org.apache.cxf.aegis.type.TypeCreationOptions">
<property name="defaultNillable" value="false"/>
<property name="defaultMinOccurs" value="1"/>
</bean>
</property>
</bean>
但是數組還有另一個問題。 對於數組,我們在WSDL中具有以下代碼:
<xsd:complexType name="ArrayOfDetails">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="Details" type="tns:Details"/>
</xsd:sequence>
</xsd:complexType>
因此不接受空數組:
org.apache.cxf.interceptor.Fault: The number of elements in {http://dto.WebServices.com}ArrayOfDetails does not meet the mini mum of 1
是否可以在數組中添加注釋,從而將minOccurs =“ 0”設置為數組的元素(而不是整個數組)? 還是可以將其設置為所有陣列的宙斯盾配置?
<xsd:element minOccurs="0" maxOccurs="unbounded" name="Details" type="tns:Details"/>
您應該使用一個映射文件 :
<mappings>
<mapping name="ArrayOfDetails">
<property name="Details" minOccurs='0'/>
</mapping>
</mappings>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.