After some extra googling rounds I found this thread that pointed to the
same problem I faced...
http://www.nabble.com/Migrating-XFire-Aegis-inheritance-to-CXF-td13536859.html
Does anyone knows if there is another method for solving this by using
annotations?
regards,
2008/4/20, Rafael Ribeiro <[EMAIL PROTECTED]>:
>
> Hi all,
>
> I have an webmethod that returns an arbitrary class. The problem is, on
> some of its executions it might return some subclass of the class that is
> expressed on the method signature. Instead of getting the actual class that
> was serialized from the webservice the client is getting the class that is
> expressed on the method. Do I have to specify anything on the classes that I
> need to serialize or on the method in order for it to correct serialize the
> expected class?
> I am sending a sample I did to reproduce the problem described above (it
> is deployed on tomcat using CXFNonSpringServlet and service is registered
> using an startupservlet):
>
> -------------------------------- IFake.java
> -------------------------------------
>
> package fake;
>
> import javax.jws.WebService;
>
> @WebService
> public interface IFake {
> public Foo fooOp();
> }
>
> -------------------------------- FakeImpl.java
> -------------------------------------
>
> package fake;
>
> public class FakeImpl implements IFake {
>
> public Foo fooOp() {
> return new FooBar();
> }
>
> }
>
>
> -------------------------------- FakeCli.java
> -------------------------------------
>
> import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
>
> import fake.IFake;
>
> public class FakeCli {
> private static IFake fakeClient;
>
> public static void main(String[] args) {
> System.out.println(getFakeClient().fooOp());
> }
>
> public static IFake getFakeClient() {
> if (fakeClient == null) {
> JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
> factory.setServiceClass(IFake.class);
> factory
> .setAddress("
> http://localhost:8080/mywebapp/services/fake");
> fakeClient = (IFake) factory.create();
> }
> return fakeClient;
> }
> }
>
> -------------------------------- Foo.java
> -------------------------------------
>
> package fake;
>
> public class Foo {
> private String foo;
>
> public String getFoo() {
> return foo;
> }
>
> public void setFoo(String foo) {
> this.foo = foo;
> }
>
> }
>
> -------------------------------- FooBar.java
> -------------------------------------
>
> package fake;
>
> public class FooBar extends Foo {
> private String fooBar;
>
> public String getFooBar() {
> return fooBar;
> }
>
> public void setFooBar(String fooBar) {
> this.fooBar = fooBar;
> }
>
> }
>
> ------------------------------------------------------------------------
>
> This webservice is registered by this call on the startupservlet:
> Endpoint.publish("/fake", new FakeImpl());
>
> and the result of the execution of FakeCli is something like:
> [EMAIL PROTECTED]
>
> If I try to cast it to FooBar I get a ClassCastException, as expected
> since this class was really instantiated as Foo instead of FooBar
>