Reputation: 1081
I'm new to Jax-ws, and I have a simple client/server application. I have an interface, a Scheduler class which implements it, and a publisher class which publishes my scheduler to localhost. I generated the stubs and have a client which calls a method on my scheduler. No problem so far.
The problem arises when I want to change my Scheduler class. If I just save changes and run the client again, the old scheduler is used by the client. If I try to publish again, I get a BindException because the port is already in use (I know it is, I'm using it!). The only work-around I have found is publishing to a different port every time and updating the stubs to the new port, but this is a terrible solution.
Is there an easier way to update code and have the client use the new changes?
Here's my client:
package assignment2;
import assignment2.endpoint.SchedulerInterface;
import assignment2.endpoint.SchedulerService;
public class Client {
public static void main(String [] args){
SchedulerService service = new SchedulerService();
SchedulerInterface scheduler = service.getSchedulerPort();
System.out.println(scheduler.getSchedule("Tuesday"));
}
}
And my publisher:
package assignment2;
import javax.xml.ws.Endpoint;
import assignment2.endpoint.Scheduler;
public class Publisher {
public static void main(String [] args){
Endpoint.publish("http://localhost:8082/WS/Scheduler", new Scheduler());
}
}
Any help is appreciated and I can supply any other code if needed.
Upvotes: 0
Views: 205
Reputation: 15241
Easier way would be re-publishing previously published service. In order to do that, you have to stop it; so instead of
Endpoint.publish("http://localhost:8082/WS/Scheduler", new Scheduler());
simply keep a reference on Endpoint object and stop it when time comes:
Endpoint ep = Endpoint.create(new Scheduler());
ep.publish("http://localhost:8082/WS/Scheduler");
..
//STOP SIGNAL ARRIVED
ep.stop();
This way you can bind on same port again and then just re-run the client (of course, updates on Scheduler class must be backward-compatible, i.e. you are not allowed to change the interface).
Upvotes: 1