【问题标题】:how to stop this javax.xml.ws.Endpoint service如何停止此 javax.xml.ws.Endpoint 服务
【发布时间】:2013-05-03 11:16:43
【问题描述】:

为了开始发布 wsdl,我喜欢下面的代码

    package my.mimos.stp.MelodyWS.webservice;

import javax.xml.ws.Endpoint;



public class Server {

    public static void main(String[] args) {

        Endpoint.publish("http://localhost:8081/Melody/MelodyService", new MelodyWS());

        System.out.println("Melody service is ready");

    }

}

如果我想停止该服务,我应该怎么做?我对 MelodyWS 进行了更改,并希望重新发布。

【问题讨论】:

    标签: web-services jakarta-ee jax-ws


    【解决方案1】:

    您必须保留对 Endpoint 对象的引用并在其上调用 stop() 方法:

    Endpoint ep = Endpoint.create(new MelodyWS());
    ep.publish("http://localhost:8081/Melody/MelodyService");
    ..
    ep.stop();
    

    【讨论】:

    • 我尝试了您的解决方案,但出现错误:“地址已在使用中:绑定”。我相信这是因为“publish()”方法。有什么提示可以解决这个问题吗?
    • @BustedSanta 不会立即停止服务。当ep.stop() 完成时,您之前绑定的端口(在本例中为 8081)应该是空闲的。您可以使用 telnet 命令进行检查(例如 telnet localhost 8081)。只有在端口空闲后,您才能重新发布服务。
    猜你喜欢
    • 2018-01-02
    • 2017-03-17
    • 1970-01-01
    • 2014-12-15
    • 2012-02-27
    • 2017-06-14
    • 2011-10-18
    • 1970-01-01
    • 2014-01-04
    相关资源
    最近更新 更多