Java 如何停止webservice端点?

Java 如何停止webservice端点?,java,web-services,Java,Web Services,我知道我需要使用端点调用stop方法。 但我不知道怎么称呼它 这是我的密码 public class Publish { public static void main(String[] args) { String address = "http://localhost:8483/cal"; Object implementor = new CalWebserviceImpl(); Endpoint endpoint = Endp

我知道我需要使用端点调用stop方法。 但我不知道怎么称呼它

这是我的密码

public class Publish {

    public static void main(String[] args) {

        String address = "http://localhost:8483/cal";
        Object implementor =  new CalWebserviceImpl();

        Endpoint endpoint = Endpoint.publish(address, implementor);
        System.out.println(endpoint.isPublished());

        endpoint.stop();


    } // main
}
这就是我得到的错误:

线程main com.sun.xml.internal.ws.server.ServerRtException:服务器运行时错误:java.net.BindException:地址已在使用中:bind 位于com.sun.xml.internal.ws.transport.http.server.ServerMgr.createContextServerMgr.java:117

我假设我收到了错误消息,因为我试图在停止端点之前重新发布它

我试图创建一个新的端点引用并使用它来停止它

        Endpoint ep = Endpoint.create(implementor);
        ep.stop();
但是我收到了同样的错误信息

我只是不知道该如何呼叫停止服务。请告知。谢谢大家!

编辑:

下面是另一次失败的尝试:

package com.website.test;
import javax.xml.ws.Endpoint;

public class Unpublish {

    Endpoint ep = null;

    public static void main(String[] args) {

        Unpublish up = new Unpublish();
        up.run();

    } // main


     public void run(){      
            String address = "http://localhost:8483/cal";
            Object implementor =  new CalWebserviceImpl();  
            // my service is already running, I believe it's publish here that's causing the issue       
            ep = Endpoint.publish(address, implementor);

            startWebService();          
   }

    private void startWebService() {

        if(ep.isPublished()){           
            System.out.println("Endpoint webservice is running!");
        }
        else{
            ep.stop();
            System.out.println("Endpoint webservice stopped!");
        }

    }

}

复制我以前读过这本书,但它并没有解决我的问题。第一步仍然是发布服务。我在我的问题中发布了上述代码的编辑版本。您是否已经运行了一些恶意实例?重新启动我的计算机终止了本地Web服务localhost:8483/cal。我只能在一次之后成功调用run方法。第二次启动调用run方法时,我发现服务已经在运行错误。因此,我试图解决的问题是如何在不使用导致服务已经运行错误的发布方法的情况下按需停止服务。但似乎我需要使用publish方法来创建最终用于停止服务的端点实例。简单地说,我如何称呼juststop而不是publishstop;可能重复的