有人可以向我解释 CXF 的以下行为吗?
我有简单的网络服务:
import javax.jws.WebMethod;
public interface MyWebService {
@WebMethod
String method1(String s);
@WebMethod
String method2(String s);
@WebMethod(exclude = true)
String methodToExclude(String s);
}
我想在接口(interface)(针对 Spring)中使用我的 methodToExclude
,但我不想在生成的 WSDL 文件中使用此方法。上面的代码正是这样做的。
但是当我向接口(interface)添加 @WebService
注释时,我得到错误:
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
有人能给我解释一下吗?有什么不同?另外我不确定它以后是否可以正常工作,但是我没有找到在使用 @WebService
时如何排除 methodToExclude
的方法。
最佳答案
@javax.jws.WebMethod(exclude=true) 用于实现:
public class MyWebServiceImpl implements MyWebService {
...
@WebMethod(exclude = true)
String methodToExclude(String s) {
// your code
}
}
不要在接口(interface)中包含方法 methodToExclude:
@WebService
public interface MyWebService {
@WebMethod
String method1(String s);
@WebMethod
String method2(String s);
}
关于java - 如何从 CXF WebService 中排除方法 - 奇怪的行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15553625/