Hi,

I just dug the code, here is the code in the JaxWsServiceConfiguration to tell which method is the WebMethod.

@Override
   public Boolean isOperation(Method method) {
       Method origMethod = method;
       method = getDeclaredMethod(method);
       if (method.getReturnType().equals(Future.class)
           || method.getReturnType().equals(Response.class)) {
           return false;
       }
if (method != null) {
           WebMethod wm = method.getAnnotation(WebMethod.class);
           if (wm != null) {
               if (wm.exclude()) {
                   return Boolean.FALSE;
               } else {
                   return Boolean.TRUE;
               }
           } else {
               if (method.getDeclaringClass().isInterface()) {
                   return hasWebServiceAnnotation(method)
                       ||  hasWebServiceAnnotation(origMethod);
               }
return hasWebServiceAnnotation(method); }
       }
       return Boolean.FALSE;
   }
private boolean hasWebServiceAnnotation(Method method) { return method.getDeclaringClass().getAnnotation(WebService.class) != null;
   }

And there are some descriptions of the WebMethod definition can explain the code.
JAX-WS 2.0 specification (Final Release April 19, 2006)
Chapter 3 "Java to WSDL 1.1 Mapping" P30.

" In order to allow for a separation between Web service interface and implementation, if the WebService annotation on the class under consideration has a endpointInterface element, then the interface referred
by this element is for all purposes the SEI associated with the class.

Otherwise, the class implicitly defines a service endpoint interface (SEI) which comprises all of the public
methods that satisfy one of the following conditions:
1. They are annotated with the javax.jws.WebMethod annotation with the exclude element set to
false or missing (since false is the default for this annotation element).
2. They are not annotated with the javax.jws.WebMethod annotation but their declaring class has a
javax.jws.WebService annotation.

For mapping purposes, this implicit SEI and its methods are considered to be annotated with the same Web
service-related annotations that the original class and its methods have.
*In pratice*, in order to exclude a public method of a class annotated with WebService and not directly specifying a endpointInterface from the implicitly defined SEI, it is necessary to annotate the method
with a WebMethod annotation with the exclude element set to true."

And Jim's suggestion is right , you just need to add the @WebMethod (exclude=true) annotation to the method that you do not want to export as a WebMethod.


Cheers,

Willem.


Jim Ma wrote:
Yes . It's the normal behavior. The runtime will reflect every method in impl class and expose it unless the
method is annotated with exclude WebMethod .
CXF also can support publishing a service with a pojo class without implementing any interface :

@WebService
public class UserWebServiceImpl {

   private UserManager userManager;
  @WebMethod (exclude=true)
   public void setUserManager(UserManager userManager) {
       this.userManager = userManager;
   }
  @WebMethod
   public User getUserById(Long id) {
       return userManager.getUser(id);
   }
}

Cheers

Jim

Julio Arias wrote:
Hi Jim,

Thanks I found that property for the @WebMethod annotation too and it works fine. But is this a normal behavior to expose everything in the implementor, I thought it would only expose the methods on my interface.

On Jul 12, 2007, at 9:05 PM, Jim Ma wrote:

Hi Julio,

I think you can add @WebMethod(exclude=true)  for the setter method.

   @WebMethod (exclude=true)
    setUserManager(UserManager userManager)

Cheers

Jim


Julio Arias wrote:
The dependencies setters from my service impl are getting expose in the WSDL even though I'm specifying the endpoint interface in the implementor. How can I hide this methods?

I have the following code and config:

+ UserWebService.java

@WebService(name = "UserService")
public interface UserWebService {
    @WebMethod
    User getUserById(@WebParam(name = "id") Long id);
}

+ UserWebServiceImpl.java

@WebService(endpointInterface = "com.rbx.test.webservices.UserWebService", name = "UserService")
public class UserWebServiceImpl implements UserWebService {

    private UserManager userManager;

    public void setUserManager(UserManager userManager) {
        this.userManager = userManager;
    }
           public User getUserById(Long id) {
        return userManager.getUser(id);
    }
}

+ Endpoint config:

<jaxws:endpoint id="userService" address="/UserService">
    <jaxws:implementor>
        <bean class="com.rbx.test.webservices.UserWebServiceImpl">
            <property name="userManager" ref="userManager"/>
        </bean>
    </jaxws:implementor>       </jaxws:endpoint>




Julio Arias
Java Developer
Roundbox Global : enterprise : technology : genius
---------------------------------------------------------------------
Avenida 11 y Calle 7-9, Barrio Amón, San Jose, Costa Rica
tel: 404.567.5000 ext. 2001 | cell: 11.506.849.5981
email: [EMAIL PROTECTED] | www.rbxglobal.com
---------------------------------------------------------------------






Julio Arias
Java Developer
Roundbox Global : enterprise : technology : genius
---------------------------------------------------------------------
Avenida 11 y Calle 7-9, Barrio Amón, San Jose, Costa Rica
tel: 404.567.5000 ext. 2001 | cell: 11.506.849.5981
email: [EMAIL PROTECTED] | www.rbxglobal.com
---------------------------------------------------------------------



Reply via email to