java - 我所有的 Web 服务方法都暴露了,无论@WebMethod如何

标签 java web-services ejb

我创建了一个 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:

  1. 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).
  2. 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/

相关文章:

java - SAX 解析器 : Retrieving HTML tags from XML

ios - 如何使用数组参数在 iOS 中创建 soap 请求?

java - 更改遗留代码中的不可变类

c# - REST 服务和大文件

java - 使用 dataFormat 作为 POJO 通过 Camel 调用 Web 服务时无法设置 SOAP header

dependency-injection - 为什么我不能在 Managed Bean 构造函数中使用 Init 属性?

java - 如何测试 EJB 是否正在 JBoss AS 7 服务器上运行

java - JBOSS-LOCAL-USER : javax. security.sasl.SaslException:无法读取服务器质询

java - 如何将文本从 Activity 传递到 Android 中的 Google Now 搜索

java - Windows Tomcat7 SSL CA 证书说是自签名的