首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当使用泛型方法时,cxf jax-ws没有用于子类的complexType。

当使用泛型方法时,cxf jax-ws没有用于子类的complexType。
EN

Stack Overflow用户
提问于 2015-02-25 16:12:51
回答 1查看 688关注 0票数 1

我不太熟悉CXF的配置。在这里,我遇到了一种情况,即对象(子类)将用于客户端,但它不会在Endpoint中声明。

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

代码语言:javascript
复制
public <T extends SuperClass> T search(Criteria criteria, ClassType type);

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

代码语言:javascript
复制
org.apache.cxf.interceptor.Fault: 
Could not determine how to read type: {http://model.fmchan.com}SubClassA

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

如果正确配置了它,则应在wsdl上显示以下内容:

代码语言:javascript
复制
<xsd:complexType name="SubClassA">
    <xsd:sequence>
        <xsd:element minOccurs="0" name="date" type="xsd:dateTime"/>
    </xsd:sequence>
</xsd:complexType>

随函附上服务器端的配置,供您参考。

代码语言:javascript
复制
<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>

谢谢你提前提供帮助。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-11-16 02:25:11

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28723961

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档