67,512
社区成员
发帖
与我相关
我的任务
分享
public interface WeatherInterface {
//天气查询
public String queryWeather(String cityName);
}
@WebService//@WebService表示该类是一个服务类需要发布其中的public方法
public class WeatherInterfaceImpl implements WeatherInterface {
public String queryWeather(String cityName) {
System.out.println("from client..."+cityName);
String weather = "晴";
System.out.println("to client..."+weather);
return weather;
}
}
public class WeatherServer {
public static void main(String[] args) {
//Endpoint发布服务
//参数解释
//1.address - 服务地址
//2.implementor - 实现类
Endpoint.publish("http://localhost:8989/weather",new WeatherInterfaceImpl());
System.out.println("发布成功!");
}
}