编写接口
@WebService
public interface JaxWsDemo {
String helloJaxWS(String userName);
}
编写接口的实现类
@WebService
public class JaxWsDemoImpl implements JaxWsDemo {
@WebMethod
@WebResult(name = “jaxWSResult”)
@Override
public String helloJaxWS(@WebParam(name = “userName”)String userName) {
return “hello,” + userName + “This is a Web Service developed through JAX-WS”;
}
}
发布服务
public class JAXWSPublishMain {
public static void main(String[] args) {
String address = “http://127.0.0.1:8888/JaxWSTest”;
Endpoint.publish(address, new JaxWsDemoImpl());
System.out.println(“WebService 服务已发布!”);
}
}