我创建了一个 session bean(3.x) 并将其放入 EAR 中。 sessionbean代码如下:
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService()
public class MESinvokeBean implements MESinvoke {
@WebMethod()
public void MESInvoke1()
{System.out.println("1");}
public void MESInvoke2()
{System.out.println("2");}
public void MESInvoke3()
{System.out.println("3");}
}
MESinvoke 类如下:
@Remote
public interface MESinvoke {
}
将其部署到 Wildfly 服务器后。我测试使用的是 SOAP Ui,尽管我只向一种方法添加 @WebMethod 注释,但所有三种方法都已公开。有人能告诉我出了什么问题吗?谢谢?
最佳答案
这是 JAX-WS 规范定义的行为。来自“基于 XML 的 Web 服务的 Java API (JAX-WS) 2.3”,第 3.3 节:
A Java class (not an interface) annotated with a javax.jws.WebService annotation can be used to define a Web service.
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 non-static or non-final methods that satisfy one of the following conditions:
- 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).
- They are not annotated with the javax.jws.WebMethod annotation but their declaring class has a javax.jws.WebService annotation.
关于java - 我所有的 Web 服务方法都暴露了,无论@WebMethod如何,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56353639/