how to stop this javax.xml.ws.Endpoint service
Asked Answered
T

1

6

i have like this below code in order to start to publish 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");

    }

}

what should i do if i want to stop that service? i have a changes in MelodyWS and would like to republish it.

Triune answered 9/5, 2013 at 3:47 Comment(0)
D
7

You have to keep a reference on the Endpoint object and call stop() method on it:

Endpoint ep = Endpoint.create(new MelodyWS());
ep.publish("http://localhost:8081/Melody/MelodyService");
..
ep.stop();
Dna answered 9/5, 2013 at 6:41 Comment(2)
I tried your solution but I am getting an error: "Address already in use: bind". I believe it's because of the "publish()" method. Any tips how to get around that?Dallis
@Dallis Stopping of the service does not occur immediately. When ep.stop() finishes, the port that you were previously bound to (in this example, 8081) should be free. You can check that with the telnet command (e.g. telnet localhost 8081). Only after the port is free, you can republish the service.Dna

© 2022 - 2024 — McMap. All rights reserved.