You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Ron Piterman <am...@sqttn.org> on 2008/03/06 19:58:24 UTC

bug when sharing same beans between endpoints.

See my post above about two services - I digged in and found out that when:
One uses two services, in two java packages.
and, both sharing the same Java Bean as parameter.
and, the Bean does not explicitly declare a namespace.

The solution is declare a namespace in the @XmlRootElement annotation,
which is not a big deal, but it should work without it.

It seems cxf uses the namespace of the service for the bean, instead of
using the bean's package name.

Here are my test files. To make them pass the test, add a namespace to
the StringBean's XmlRootElement
-----------------------------------------------------------------------------------
package test.a;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

@WebService
public interface HelloService {
   
    @WebMethod
    public String greet( @WebParam(name="w") StringBean b1 );
   
}

-----------------------------------------------------------------------------------
package test.a;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

@WebService(
        endpointInterface="test.a.HelloService")
public class HelloServiceImpl implements HelloService {

    @WebMethod
    public String greet( @WebParam(name="w") StringBean b1) {
        return b1.getWhat();
    }
   
}

-----------------------------------------------------------------------------------
package test.a;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class StringBean {
   
    private String what;
   
    public StringBean() {}

    public StringBean(String what) {
        super();
        this.what = what;
    }

    @XmlElement(name="what")
    public String getWhat() {
        return what;
    }

    public void setWhat(String what) {
        this.what = what;
    }
   
}

-----------------------------------------------------------------------------------
package test.b;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

import test.a.StringBean;

@WebService
public interface SayService {
   
    @WebMethod
    public String say( @WebParam(name="a") StringBean b1 );
   
}

-----------------------------------------------------------------------------------
package test.b;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

import test.a.StringBean;

@WebService(
        endpointInterface="test.b.SayService")
public class SayServiceImpl implements SayService {

    @WebMethod
    public String say( @WebParam(name="a") StringBean b1) {
        return b1.getWhat();
    }

}