【问题标题】:cxf jax-ws no complexType for subclasses while using generic methodcxf jax-ws 在使用泛型方法时没有子类的 complexType
【发布时间】:2015-11-16 10:25:11
【问题描述】:

我对 CXF 配置不是很熟悉。在这里我遇到了一个对象(子类)将用于客户端但它没有在 Endpoint 中声明的情况。

例如,有一个超类“SuperClass”和两个子类“SubClassA”和“SubClassB”。 Endpoint 中声明了以下方法:

public <T extends SuperClass> T search(Criteria criteria, ClassType type);

因此,这些子类不会出现在 Endpoint 中,这会导致它们的 complexType 在 wsdl 中丢失。客户端调用子类的对象时提示没有读取类型的错误。

org.apache.cxf.interceptor.Fault: 
Could not determine how to read type: {http://model.fmchan.com}SubClassA

所以在这里我想寻求一种解决方案,将这些子类添加到wsdl中,以便在客户端正确调用。

如果配置正确,wsdl上应该会显示如下:

<xsd:complexType name="SubClassA">
    <xsd:sequence>
        <xsd:element minOccurs="0" name="date" type="xsd:dateTime"/>
    </xsd:sequence>
</xsd:complexType>

附上服务器端的配置供大家参考。

<import resource="classpath:META-INF/cxf/cxf.xml" />

<bean id="aegisContext" class="org.apache.cxf.aegis.AegisContext"
    p:writeXsiTypes="true" scope="prototype" />
<bean id="aegisBean" p:aegisContext-ref="aegisContext"
    class="org.apache.cxf.aegis.databinding.AegisDatabinding"
    scope="prototype" />

<bean id="genericServiceImpl" class="com.fmchan.service.SomeEndpointImpl"/>

<jaxws:endpoint implementor="#genericServiceImpl"
    address="${service.address}">
    <jaxws:serviceFactory>
        <ref bean="jaxws-and-aegis-service-factory" />
    </jaxws:serviceFactory>
</jaxws:endpoint>

<bean id="jaxws-and-aegis-service-factory"
    class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean"
    scope="prototype">
    <property name="dataBinding">
        <bean class="org.apache.cxf.aegis.databinding.AegisDatabinding" />
    </property>
</bean>

提前感谢您的帮助。

【问题讨论】:

    标签: soap wsdl cxf jax-ws-customization


    【解决方案1】:

    我想出的最简单的解决方案是创建一个虚拟方法,包括那些子类 A 和 B 作为端点的参数。这可能不是最好的解决方案,我仍在寻找更好的解决方案。

    【讨论】:

      猜你喜欢
      • 2011-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多