MyEclipse10
java运行环境
1、编写接口类:package com.test;public interface WeatherInterface { String queryWeather(String cityName);}
2、编写实现类:package com.test;import javax.jws.WebService;@WebServicepublic class WeatherInterfaceImpl implements WeatherInterface { public String queryWeather(String cityName) { System.out.println('接收到客户端发送的城市名称:'+cityName); String result='晴,高温预警'; return result; }}
3、编写可执行程序类:package com.test;import javax.xml.ws.Endpoint;public class WeatherServer { public static void main(String[] args) { //发布服务 Endpoint.publish('http://127.0.0.1:11111/weather', new WeatherInterfaceImpl()); }}
4、运行该程序;5、报错:runtime modeler error: Wrapper class com.shu.function.jaxws.QueryWeather is not found. Have you run APT to generate them?
解决办法:6、在该类上新建Web Service;
7、设置为create web service from java class;
8、选择一个java class;
9、运行该应用程序,则在class中生成了一个新类;且在该项目的文件夹下生成了新的文件;
10、运行webservice,则运行成功;
综上所述,在Java环境下部署WebService应用成功。
报错时,需要新建web service类