soapwsdlcxfjax-ws-customization

cxf jax-ws no complexType for subclasses while using generic method


I am not quite familiar with CXF configuration. Here I am encountering a situation that a object (subclass) is going to be used for client but it does not declare in Endpoint.

For example, there is a super class "SuperClass" and two subclasses "SubClassA" and "SubClassB". The following method is declared in Endpoint:

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

Therefore, those subclasses do not appear in Endpoint and it causes that their complexType is missing in wsdl. Error saying no read type is prompted when the object of subclass is called from client.

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

So here I would like to seek for a solution to add those subclasses into wsdl so as to be called properly on client side.

If it is properly configured, the following should be shown on wsdl:

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

Enclosed is the configuration on server side for your reference.

<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>

Thank you for any help in advance.


Solution

  • The simplest solution I come up with is to create a dummy method including those subclasses A and B as parameters for endpoint. It probably isn't the best solution and I still seek for better one.