@WebService
public interface HelloWorld {
@WebMethod
String sayHello(String name);
}
@WebService(endpointInterface = "com.example.HelloWorld")
public class HelloWorldImpl implements HelloWorld {
@Override
public String sayHello(String name) {
return "Hello, " + name + "!";
}
}
public class HelloWorldPublisher {
public static void main(String[] args) {
HelloWorld helloWorld = new HelloWorldImpl();
String url = "http://localhost:8080/HelloWorld";
Endpoint.publish(url, helloWorld);
System.out.println("Web service published at: " + url);
}
}