I have the following classes that implements an interface and publishes an endpoint.
SayHelloImpl.java
@WebService(endpointInterface = "com.suture.self.wsdl.SayHello")
@HandlerChain(file = "handler-chain.xml")
public class SayHelloImpl implements SayHello {
...
...
}
EndpointPublisher.java
public class EndpointPublisher {
public static void main(String[] args) {
Endpoint.publish("http://sutureself.com/greeter", new SayHelloImpl());
}
}
At present, it all works perfectly for SayHello, but now I want to add another web service, SayGoodbye (below)
SayGoodbyeImpl.java
@WebService(endpointInterface = "com.suture.self.wsdl.SayGoodbye")
@HandlerChain(file = "handler-chain.xml")
public class SayGoodbyeImpl implements SayGoodbye {
...
...
}
How do I now publish the endpoint with two (or more) implementors? I have tried implementing both interfaces in the one class, which is fine, but the number of interfaces could grow, and this could get very cluttered quickly. Ideally, I want to implement a single interface in a single class.
You can define multiple WebMethod in a WebService.
@WebService
@HandlerChain(file = "handler-chain.xml")
public class WSImpl implements SayHello, SayGoodbye {
... // impl SayHello methods
... // impl SayGoodBye methods
}
and
Endpoint.publish("http://sutureself.com/greeter", new WSImpl());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.