【随记】cxf的webservice接口实现
来源:互联网 发布:aoi检测怎么编程 编辑:程序博客网 时间:2024/06/05 15:44
步骤
1)定义接口。如TestInterface。
2)定义实现类
@WebService(endpointInterface="cn.david.test.TestInterface",targetNamespace="http://test.ws.david.cn/")public class TestDaoImp implements TestInterface {}
3)web.xml配置
<servlet> <servlet-name>CXFServlet</servlet-name> <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>CXFServlet</servlet-name> <url-pattern>/cxf/*</url-pattern> </servlet-mapping>
4)启动服务(可与其他框架整合启动)如果自己启动的话,可以采用以下方式。
public static void main(String[] args) { System.out.println("Server is starting..."); TestInterface readerService = new TestDaoImp(); Endpoint.publish("http://test.ws.david.cn/readService",readerService); System.out.println("Server is started..."); }
5)客户端访问webservice接口
String address = "http://test.ws.david.cn/readService"; //此处最好用系统参数JaxWsProxyFactoryBean bean = new JaxWsProxyFactoryBean();bean.setAddress(address); bean.setServiceClass(TestInterface.class);TestInterface ws = (TestInterface) bean.create();System.out.println(ws.getCitiesByCountry("China"));System.out.println(ws.getWeather("Shanghai", "China"));
0 0
- 【随记】cxf的webservice接口实现
- CXF方式实现webService接口
- 简单的WebService实现- cxf
- Android调用基于cxf的WebService接口
- cxf调用webservice接口
- CXF配置Webservice接口
- webservice+cxf接口开发
- 使用CXF实现Webservice的服务接口提供以及相关的客户端实现
- cxf实现的webservice,调用接口的方法后出现异常
- WebService的实现之二CXF实现
- cxf+spring发布webservice接口及接口的调用
- cxf+spring发布webservice接口及接口的调用
- cxf+spring发布webservice接口及接口的调用
- cxf+spring发布webservice接口及接口的调用
- 简单记录cxf框架来实现webservice接口
- webService 使用CXF 实现简单的helloworld
- WebService的实现——cxf
- cxf实现rest风格的webservice
- JZ2440 usb设备驱动(跟着韦老师学)
- 把数组变成以特定字符连接的字符串
- 如何使用MySQL的 group_concat函数
- Activity的生命周期
- 工具类
- 【随记】cxf的webservice接口实现
- [Java并发包学习七]解密ThreadLocal
- 自己动手写HTTP框架:异步任务篇
- 分布式设计与开发(二)------几种必须了解的分布式算法
- DOM解析XML文件并添加到数据库中
- UIApplication深入研究
- opencv批处理提取图像的特征
- volley源码分析
- Java的递归