webservice第一天
来源:互联网 发布:uu黑历史知乎 编辑:程序博客网 时间:2024/04/30 23:26
最近入坑webservice。看着视频一步一步学下去。
出现一个错误:Exception in thread "main" com.sun.xml.ws.model.RuntimeModelerException: runtime modeler error: Wrapper class com.ws.publish.jaxws.SelectMaxAgeStudent is not found. Have you run APT to generate them?
百度一大堆,终于找到原因。原来是jdk版本太低。
解决:
jaxws.SelectMaxAgeStudent is not found 中jaxws,在之前学习过手动dos命令下生成Webservice想到我少了JAX-WS2.1.2,jar包;Build Path加入所有jar后还是报错;原因就是我的jdk1.6版本不是最新,需要在实现类前加入@SOAPBinding(style = SOAPBinding.Style.RPC),运行!一切正常
tip:
@SOAPBinding(style = SOAPBinding.Style.RPC)指定SOAP消息样式,有两个枚举值:SOAPBinding.Style.DOCUMENT(默认)和 SOAPBinding.Style.RPC,可以对比这两种方式生成的wsdl会有所不同,而且生成的客户端代码也会有所不同。
还有,自己居然会犯最低等级的错误!下了jdk却没有配环境变量!!
客户端代码:
//wsimpost生成的代码。
//创建服务视图对象
WebServiceInterfaceImplService webServiceInterfaceImplService = new WebServiceInterfaceImplService();
//通过服务视图创建portType
WebServiceInterfaceImpl webServiceInterfaceImpl = webServiceInterfaceImplService.getWebServiceInterfaceImplPort();
//通过portType调用服务方法
String result = webServiceInterfaceImpl.queryWeather("北京");
服务端:
//单独的service,用来开启服务。
Endpoint.publish("http://192.168.8.1:12345/weather", new WebServiceInterfaceImpl());
//还需写一个接口以及其实现类
@WebService //添加注解
@SOAPBinding(style = SOAPBinding.Style.RPC) //添加注解
public class WebServiceInterfaceImpl implements WebServiceInterface {
public String queryWeather(String cityname) {
System.out.println("from client" + cityname);
String result = "多云";
return result;
}
}
- webservice第一天
- webservice(第一天)
- webservice第一天,入门
- webService第一天
- 传智播客webService第一天课堂笔记
- MY--jaxws-webservice编程第一天
- webservice编写接口 第一天实现结果
- 5天学会jaxws-webservice编程第一天
- jax-ws之webservice security(安全)教程第一天
- 5天学会jaxws-webservice编程第一天
- jax-ws之webservice security(安全)教程第一天
- 5天学会jaxws-webservice编程第一天 .
- 5天学会jaxws-webservice编程第一天
- 5天学会jaxws-webservice编程第一天
- jax-ws之webservice security(安全)教程第一天
- 5天学会jaxws-webservice编程第一天
- 5天学会jaxws-webservice编程第一天
- jax-ws之webservice security(安全)教程第一天
- NodeJs 安全
- 数据库 select @@identity说明
- Python中指针式传递的函数遇到的问题
- Android性能测试之概述(一)
- 信号处理国际会议排名
- webservice第一天
- TCP的那些事
- 查找算法总结
- (4.3)uboot详解——异常和异常向量
- ListView嵌套GridView显示不全解决方法
- 【ZJOI2009】狼和羊的故事
- host-only 与bridge方式的区别
- 抽象接口的作用
- PUOJ_Stars