多语言展示
当前在线:353今日阅读:138今日分享:34

如何解决Have you run APT to generate them?

在调用WebService时,报错Have you run APT to generate them,该如何解决?
工具/原料
1

MyEclipse10

2

java运行环境

方法/步骤
1

1、编写接口类:package com.test;public interface WeatherInterface {    String queryWeather(String cityName);}

2

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

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

4、运行该程序;5、报错:runtime modeler error: Wrapper class com.shu.function.jaxws.QueryWeather is not found. Have you run APT to generate them?

5

解决办法:6、在该类上新建Web Service;

6

7、设置为create web service from java class;

7

8、选择一个java class;

8

9、运行该应用程序,则在class中生成了一个新类;且在该项目的文件夹下生成了新的文件;

9

10、运行webservice,则运行成功;

10

综上所述,在Java环境下部署WebService应用成功。

注意事项

报错时,需要新建web service类

推荐信息