[英]How to exclude method from CXF WebService - strange behavior
Can someone explain to me the following behavior of CXF? 有人可以向我解释一下CXF的以下行为吗?
I have simple WebService: 我有简单的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. 我想在接口(对于Spring)中使用我的
methodToExclude
,但我不想在生成的WSDL文件中使用此方法。 The code above does exactly that. 上面的代码确实如此。
But when I add @WebService
annotation to the interface I get error: 但是当我向界面添加
@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.
org.apache.cxf.jaxws.JaxWsConfigurationException:@ javax.jws.WebMethod(exclude = true)不能在服务端点接口上使用。 Method: methodToExclude
方法: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
. 另外我不确定它以后是否能正常工作,但是当我使用
@WebService
时,我没有找到如何排除methodToExclude
的方法。
The @javax.jws.WebMethod(exclude=true) is used on the implementation: @ javax.jws.WebMethod(exclude = true)用于实现:
public class MyWebServiceImpl implements MyWebService {
...
@WebMethod(exclude = true)
String methodToExclude(String s) {
// your code
}
}
Don´t include the method methodToExclude in the interface: 不要在接口中包含方法methodToExclude:
@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. 摆脱所有@WebMethod,因为它们是可选的,只有在必须排除方法时才需要。
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 仅将@WebMethod(exclude = true)添加到Interface Implementation
public class MyWebServiceImpl implements MyWebService { String method1(String s) { // ... } String method2(String s) { // ... } @WebMethod(exclude = true) String methodToExclude(String s) { // ... } }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.