我正在尝试通过 JAX-WS 注释公开 Web 服务方法。我见过的许多示例都引用了 EndPoint.publish() 方法来在独立应用程序中快速建立服务(例如来自 Java Web Services:Up and Running, 1st Edition):
public class TimeServerPublisher {
public static void main(String[ ] args) {
// 1st argument is the publication URL
// 2nd argument is an SIB instance
Endpoint.publish("http://127.0.0.1:9876/ts", new TimeServerImpl());
}
}
我缺少的一件事是如何在现有应用程序中完成基本相同的事情。我会做一个servlet来处理这个吗?在现有 WAR 文件中发布此服务的正确方法是什么?