CXF实现服务端和客户端集成
来源:互联网 发布:金枝玉叶电影知乎 编辑:程序博客网 时间:2024/06/03 15:58
一、SEI的定义
假设有以下SEI定义:
- @WebService
- public interface OrderProcess {
- public String processOrder(Order order);
- }
(实现端省略)
二、Server端发布
则最简单的发布Server的方式可以如下:
- Endpoint.publish("http://localhost:8181/orderProcess", new OrderProcessImpl());
或者是spring的方式:
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:jaxws="http://cxf.apache.org/jaxws"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="
- http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
- <import resource="classpath:META-INF/cxf/cxf.xml" />
- <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
- <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
- <jaxws:endpoint id="orderProcess"
- implementor="com.liulutu.liugang.cxf.jaxws.OrderProcessImpl" address="http://localhost:8090/orderProcess" />
- </beans>
三、Client端调用
- Service service = Service.create(new URL("<wsdlfilepath>"),
- new QName("namespace", "servicename"));
- OrderProcess port = orderProcessService.getPort(OrderProcess.class);
- String s = port.processOrder(<arg>);
- System.out.println(s);
或者Spring的方式:
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:jaxws="http://cxf.apache.org/jaxws"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://cxf.apache.org/jaxws
- http://cxf.apache.org/schemas/jaxws.xsd">
- <jaxws:client id="orderClient"
- serviceClass="com.liulutu.liugang.cxf.codefirst.OrderProcess"
- address="http://localhost:8181/orderProcess" />
- </beans>
然后在Java代码里:
- ClassPathXmlApplicationContext xmlApplicationContext = new ClassPathXmlApplicationContext(
- "/META-INF/spring/jaxwsspringclient.xml");
- OrderProcess bean = xmlApplicationContext.getBean(OrderProcess.class);
- System.out.println(bean.processOrder(<order>));
0 0
- CXF实现服务端和客户端集成
- CXF和Spring整合实现WebService服务端、客户端
- CXF创建webservice客户端和服务端
- CXF创建webservice客户端和服务端
- CXF创建webservice客户端和服务端
- CXF创建webservice客户端和服务端
- CXF开发服务端(Server)和客户端(Client)
- cxf开发webservice服务端和客户端
- Spring集成Thrift,实现服务端和客户端代理
- CXF创建webservice服务端、客户端,与spring集成
- Spring集成CXF搭建WebService服务端与客户端
- spring集成CXF服务端
- webservice 完整 实现方式 服务端 客户端 (cxf)
- CXF与Spring集成服务端
- CXF密码验证_服务端和客户端配置
- WebService-03-使用CXF开发服务端和客户端
- CXF之用spring配置服务端和客户端实例
- WEB项目 CXF与Spring整合服务端和客户端创建
- Python中的random模块
- smarty中display和fetch的区别
- 常用命令——文件处理命令
- Pomelo网易开源基于Node.js的游戏服务器框架pomelo
- curl应用总结(一)
- CXF实现服务端和客户端集成
- ListView加载数据的那些事
- 解决应用服务器变为集群后的Session问题
- iOS runtime运行时详解续
- uboot重定位详解
- Java并发编程:volatile关键字解析(五.使用volatile关键字的场景)
- 三大类站点关键词,各位SEOer知道吗?
- PDF阅读器系列之--MuPDF源码分析过程(一)
- GIMP 创建arm LCD上显示的图片