wsgen exposes methods that are not annotated with @WebMethod

I have the following minimal webservice defined:

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;

@WebService
public class DummyWS {

  public static void main(String[] args) {
    final String url= "http://localhost:8888/Dummy";
    final Endpoint endpoint= Endpoint.create(new DummyWS());
    endpoint.publish(url);
  }

  @WebMethod
  public void putData(final String value) {
    System.out.println("value: "+value);
  }

  @WebMethod
  public void doSomething() {
    System.out.println("doing nothing");
  }


  public void myInternalMethod() {
    System.out.println("should not be exposed via WSDL");
  }
}

As you can see I have two methods I want to expose, since they are annotated with @WebMethod: putData and doSomething. But when running wsgen, it generates a WSDL that contains the myInternalMethod although it is not annotated.

Do I have a misconfiguration here? Why is a method exposed that is not annotated with @WebMethod?

Answers


OK, I found it. Per default all public methods are exposed. To exclude a method one must annotate it with @WebMethod(exclude=true). This is quite a strange requirement, because it means that I only have to annotate those methods with @WebMethod that I do not want to expose.

This is the correct code then:

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;

@WebService
public class DummyWS {

  public static void main(String[] args) {
    final String url= "http://localhost:8888/Dummy";
    final Endpoint endpoint= Endpoint.create(new DummyWS());
    endpoint.publish(url);
  }

  public void putData(final String value) {
    System.out.println("value: "+value);
  }

  public void doSomething() {
    System.out.println("doing nothing");
  }


  @WebMethod(exclude=true)
  public void myInternalMethod() {
    System.out.println("should not be exposed via WSDL");
  }
}

Need Your Help

If you apply CSS font-size to the body element how do you handle nesting tags and inheritance?

html css

I am redesigning a site with a lot of old content. The primary design change is making the site elastic to fill various screen sizes. I am using the font-size in the body element as the mechanism...