【问题标题】:CXF: Set minOccurs=0 for elements of the arraysCXF:为数组的元素设置 minOccurs=0
【发布时间】:2010-02-26 13:31:25
【问题描述】:

我们使用 CXF 框架和用于 java 服务器和 .NET 客户端的 aegis 映射器。 默认情况下,我们为 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"/>

【问题讨论】:

    标签: java web-services cxf aegis


    【解决方案1】:

    你应该使用mapping file:

     <mappings>
      <mapping name="ArrayOfDetails">
        <property name="Details" minOccurs='0'/>
      </mapping>
    </mappings>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-09
      • 2012-11-30
      • 1970-01-01
      • 2014-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-21
      相关资源
      最近更新 更多