Can someone explain to me the following behavior of CXF?
I have simple WebService:
import javax.jws.WebMethod;
public interface MyWebService {
@WebMethod
String method1(String s);
@WebMethod
String method2(String s);
@WebMethod(exclude = true)
String methodToExclude(String s);
}
I want to have my methodToExclude
in interface (for Spring), but I do not want to have this method in generated WSDL file. The code above does exactly that.
But when I add @WebService
annotation to the interface I get error:
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
public interface MyWebService {
@WebMethod
String method1(String s);
@WebMethod
String method2(String s);
@WebMethod(exclude = true)
String methodToExclude(String s);
}
org.apache.cxf.jaxws.JaxWsConfigurationException: The @javax.jws.WebMethod(exclude=true) cannot be used on a service endpoint interface. Method: methodToExclude
Can someone explain this to me? What's the difference? Also I'm not sure if it will work fine later, but I didn't find the way how to exclude the methodToExclude
when I use @WebService
.
The @javax.jws.WebMethod(exclude=true) is used on the implementation:
public class MyWebServiceImpl implements MyWebService {
...
@WebMethod(exclude = true)
String methodToExclude(String s) {
// your code
}
}
Don´t include the method methodToExclude in the interface:
@WebService
public interface MyWebService {
@WebMethod
String method1(String s);
@WebMethod
String method2(String s);
}
Its late but I would like to chip in my answer.
Get rid of all the @WebMethod as they are optional and needed only when a method must be excluded.
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
public interface MyWebService {
String method1(String s);
String method2(String s);
String methodToExclude(String s);
}
Add @WebMethod(exclude = true) to Interface Implementation only
public class MyWebServiceImpl implements MyWebService {
String method1(String s) {
// ...
}
String method2(String s) {
// ...
}
@WebMethod(exclude = true)
String methodToExclude(String s) {
// ...
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With