<dependency>
<groupId>jakarta.xml.ws</groupId>
<artifactId>jakarta.xml.ws-api</artifactId>
<version>2.3.3</version>
</dependency>
import jakarta.jws.WebMethod;
import jakarta.jws.WebService;
@WebService
public class MyWebService {
@WebMethod
public String sayHello(String name) {
return "Hello, " + name + "!";
}
}
import jakarta.xml.ws.Endpoint;
public class WebServicePublisher {
public static void main(String[] args) {
String url = "http://localhost:8080/mywebservice";
Endpoint.publish(url, new MyWebService());
System.out.println("Web service is published at " + url);
}
}