package webservice;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;
/**
* 只有加了WebService注解的类才有可能发布Web服务
* @author Dqd
*
*/
@WebService
public class HelloService {
/**
* 提供一个合法的方法:不能是static或者是final的
* @param name
* @return
*/
public String sayHello(String name){
return "您好"+name;
}
public static void main(String[] args) {
String ip = "http://127.0.0.1:16789/hello";
HelloService helloService = new HelloService();
Endpoint.publish(ip, helloService);
System.out.println("Ready??...");
}
}
使用jdk发布WebService服务
最新推荐文章于 2023-06-05 16:08:10 发布
本文介绍了一个使用Java实现的简单Web服务发布示例。通过@WebService注解定义了一个名为HelloService的服务类,并实现了sayHello方法。该方法接收一个字符串参数并返回包含问候语的字符串。此外,还展示了如何使用Endpoint.publish方法发布该Web服务。
469

被折叠的 条评论
为什么被折叠?



