在 Wildfly 中更改公开的 WebService URL

Change exposed WebService URL in Wildfly

我有一个 Web 应用程序目前在 Glassfish 4.0 下工作,我想修改它以在 Wildfly 8.2 下工作。我目前遇到的问题是:

我有一些 Web 服务(带有注释 @WebService)目前发布在 /ws/

f.e。 "PanelService" 会暴露在 /myAppContextRoot/ws/PanelService

我通过将 Glassfish-WS-Servlet(ergo JAXWS-RI)绑定到 web.xml 中的 /ws/* 来做到这一点。 在不使用 Wildfly 特定注释的情况下,是否有一种比较适合 Wildfly 的方法 - 仅通过配置?我不想 jboss-classes 在我的 classpath.

我目前的 "solution" 是将 JAXWS-RI 添加到类路径并发布服务两次 - 通过 JBoss-WSJAXWS-RI :-(

€编辑:

Terrence Curran 的解决方案确实有效......但是......我不得不添加一些小的改动。

.

<webservices>
    <context-root>myApp/ws</context-root>
</webservices>

知道了。

在 Wildfly 下,可以将 WebServices 映射为 web.xml 中的 "servlets"。 所以我只需要删除 JAX-WS RI 并将以下代码段添加到 web.xml:

<servlet>
    <servlet-name>PanelService</servlet-name>
    <servlet-class>org.myapp.ws.PanelService</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>PanelService</servlet-name>
    <url-pattern>/ws/PanelService</url-pattern>
</servlet-mapping>

我还会考虑在 jboss-webservices.xml 文件中定义上下文根。这样您就可以避免修改 web.xml,这会破坏您在 GlassFish 中的部署。

<webservices>
    <context-root>ws</context-root>
</webservices>

@cljk 不错的捷径。

为了完成您的回答,如果您不想弄乱 web.xml,@WebServlet 注释也可以:

@WebServlet("/soap/test")
@WebService(name = "test", serviceName = "testService", portName = "testPort")
@SOAPBinding(style = Style.DOCUMENT)
@MTOM(enabled = true, threshold = 4194304)
public class SoapTestService
{
    ...
}

你会得到:

JBWS024061: Adding service endpoint metadata: id=it.shape.myapp.ws.soap.test.SoapTestService
 address=http://localhost:8080/myapp/soap/test
 implementor=it.shape.myapp.ws.soap.test.SoapTestService
 serviceName={http://test.soap.ws.myapp.shape.it/}testService
 portName={http://test.soap.ws.myapp.shape.it/}testPort
 annotationWsdlLocation=null
 wsdlLocationOverride=null
 mtomEnabled=true

在 Wildfly 10.0 上测试。0.Final