You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Frederic Soulier <fr...@wallaby.uklinux.net> on 2008/02/07 17:31:05 UTC

Inheritance in CXF

Hi

I can't find any information on inheritance in the CXF doc.
The only info I found was on the XFire site and the Jira issue CXF-1164

Say, I have:

public class Parent {
    private String p1;
(+ get/set accessors)
}
public class Child extends Parent {
    private String c1;
    private String c2;
(+ get/set accessors)	
}

The SOAP exposed interface is:
public interface IExample {
    public Parent findSomething(... params...);
}

The implementation is:
public class ExampleImpl implements IExample {
    public Parent findSomething(... params...) {
       return new Child();
    }
}

The WSDL shows:
...
<xsd:complexType name="Child">
   <xsd:sequence>
     <xsd:element minOccurs="0" name="p1" nillable="true"  
type="xsd:string"/>
     <xsd:element minOccurs="0" name="c1" nillable="true"  
type="xsd:string"/>
     <xsd:element minOccurs="0" name="c2" nillable="true"  
type="xsd:string"/>
   </xsd:sequence>
</xsd:complexType>
...


Now the client cannot do something like:
    Child ch = (Child)service.findSomething(... params ...);
as this will fail with a ClassCastException.

So is there a way to define inheritance (annotation? Spring config?)  
for the model objects being returned so the WSDL generated shows the  
inheritance properly allowing the clients to cast objects accordingly?

Thx.

--
Frederic P. Soulier
OpenPGP key available on http://pgpkeys.mit.edu/
1024D/BA6700ED   49A6 8E8E 4230 8D41 1ADE  B649 3203 1DD2 BA67 00ED