如何在 WildFly 中配置 EJB WebServices(in ear)

How to configure EJB WebServices in WildFly (in ear)

我有一个 EAR 项目,部署在 WildFly 10.1 上。0.Final 这个 EAR 由一些罐子和战争组成。我的 jar 文件中有一个 WebService。

我不清楚如何配置我的项目。 我在 google 和调试器上花了很多时间...所以我需要帮助 )

我的目标:在 ear/server 级别上为我的 JAR 中的 EJB WebService 设置默认 AuthType/Security-domain。

对于安全域,我在以下位置找到了配置:

此外,我如何理解 - ejb 属性对于 ejb beans webservices 的优先级高于 webservices 属性

但是我如何设置默认的 auth metod BASIC? class 上没有注释。我找不到( WEB-INF/web.xml 和 jboss-web.xml 不影响我的网络服务。

正在使用 maven?

在此存储库中 https://github.com/wildfly/quickstart you can find lot of examples of projects for deploy in wildfly. Specifically for web service using ejb this example is usefull https://github.com/wildfly/quickstart/tree/10.x/jaxws-ejb。请注意,在此项目中,需要在 jboss-web.xml:

上指示上下文根
<jboss-web>
    <context-root>/yourpath</context-root>
</jboss-web>

Web 服务的配置是通过注释执行的。

/**
* @author rsearls@redhat@com
*/
@Stateless
@Remote(EJB3RemoteInterface.class)
@WebService
@SOAPBinding(style = SOAPBinding.Style.RPC)
public class EJB3Bean01 implements EJB3RemoteInterface {
    @WebMethod
    public String echo(String input) {
        return "EJB3Bean01 returning: " + input;
    }

}

来自 web.xml 的属性仅适用于 war 部署。 我发现只有一种方法可以使用 Web 服务配置 ejb jar 部署(所有端点和部署都在一个地方)。

据我们所知,WildFly 使用 Undertow。 我们可以定义Servlet扩展http://undertow.io/undertow-docs/undertow-docs-1.2.0/#servlet-extensions

添加src/main/resources/META-INF/services/io.undertow.servlet.ServletExtension。 然后,在这个文件中添加我们的 UndertowDeploymentExtension(实现 ServletExtension)。

然后,在 handleDeployment 方法中添加如下内容: deploymentInfo.setLoginConfig(新登录配置(javax.servlet.http.HttpServletRequest.BASIC_AUTH,REALM_NAME));

现在,我们没有 LoginConfig 的 jar 部署将使用我们的自定义 LoginConfig 进行初始化(我们可以省略 @WebContext)。 有关详细信息,您可以在 WebMetaDataCreator.createLoginConfig (wildfly-webservices-server-integration-10.1.0.Final.jar)

进行调试

快速预览:https://github.com/wildfly/wildfly/blob/master/webservices/server-integration/src/main/java/org/jboss/as/webservices/tomcat/WebMetaDataCreator.java#L276

此外,您可以阅读此建议:http://lists.jboss.org/pipermail/undertow-dev/2016-December/001801.html