【参考:http://cxf.apache.org/docs/jax-ws-configuration.html】
【参考:http://cxf.apache.org/docs/writing-a-service-with-spring.html】
【参考:http://cxf.apache.org/docs/simple-frontend-configuration.html】
在上节里,我们介绍了JAX-WS的创建Service和调用Service的方式。这节介绍另种实现方式:Simple。
除了支持通过读取jax-ws的annotation来生成webservice,CXF也支持直接从一个类对象生成webservice服务,这就是这里要介绍的simple frontend方式。
一、Service接口定义
public interface OrderProcess { String processOrder(Order order); }
没有任何jax-ws相关的annotation
二、Server的发布
ServerFactoryBean bean = new ServerFactoryBean(); bean.setAddress("http://localhost:8181/cxf/simple"); bean.setServiceBean(new OrderProcessImpl()); bean.setServiceClass(OrderProcess.class); bean.create();
或者是Spring方式:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:simple="http://cxf.apache.org/simple" xmlns:soap="http://cxf.apache.org/bindings/soap" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd http://cxf.apache.org/simple http://cxf.apache.org/schemas/simple.xsd"> <simple:server id="orderProcess" serviceClass="com.liulutu.liugang.cxf.simple.OrderProcess" address="http://localhost:8181/cxf/simple"> <simple:serviceBean> <bean class="com.liulutu.liugang.cxf.simple.OrderProcessImpl" /> </simple:serviceBean> </simple:server> </beans>
三、Client端的实现
ClientProxyFactoryBean client = new ClientProxyFactoryBean(); client.setAddress("http://localhost:8181/cxf/simple"); client.setServiceClass(OrderProcess.class); OrderProcess orderProcess = (OrderProcess)client.create(); String s = orderProcess.processOrder(<order>); System.out.println(s);
或者是Spring的方式:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:simple="http://cxf.apache.org/simple" xmlns:soap="http://cxf.apache.org/bindings/soap" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd http://cxf.apache.org/simple http://cxf.apache.org/schemas/simple.xsd"> <simple:client id="orderClient" serviceClass="com.liulutu.liugang.cxf.simple.OrderProcess" address="http://localhost:8181/cxf/simple"> </simple:client> </beans>
然后在java代码里:
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("/com/liulutu/liugang/cxf/simple/client.xml"); OrderProcess bean = context.getBean("orderClient", OrderProcess.class); String processOrder = bean.processOrder(<order>); System.out.println(processOrder);
相关推荐
Maven坐标:org.apache.cxf:cxf-rt-frontend-simple:3.0.1; 标签:cxf、rt、apache、simple、frontend、jar包、java、API文档、中文版; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览...
cxf spring server client demo.rar soap webservice
本实例是基于CXF的一个客户端的实现,使用maven生成客户端代码,集成spring配置客户端实现类,访问外部接口。“CXF契约优先开发方式”中的实例为服务器端代码。
Maven坐标:org.apache.cxf:cxf-rt-rs-client:3.0.1; 标签:cxf、rt、apache、client、jar包、java、API文档、中文版; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性...
cxfserver+spring+mybatis
cxf+spring+client+springmvc
关于java CXF 一个简单的例子,所用jar包请自己下载 谢谢
SpringBoot+Mybatis+CXF框架,实现Restful api与 WebService api接口的大实验
使用webservice的cxf做server与client例子
CXF实现SSL安全验证,实现https的WebService
CXF 编写 WebServer DEMO,使用 CXF 工具编写 WebServer
2、将cxf_jar包文件夹下所有包,拷至MyCXFService与MyCXFClient项目WebRoot\WEB-INF\lib\cxf_2.7.8 目录下(注意:两个项目都需要这些jar包) 3、将两个项目都导入myEclipse 4、将MyCXFService与MyCXFClient 一起...
使用spring集成cxf,在两个web ...server端使用spring+springmvc+mybatis+cxf,client端使用struts2+spring+hibernate+cxf 两个工程均为myeclipse project,包含所有除myeclipse自带以外所有jar 内附 使用文档,数据库脚本
CXF源码:CXF_Spring源码 CXF源码:CXF_Spring源码
cxf实现soap webservice服务,服务端\客户端均与spring结合使用,多种方式实现,花了三天时间弄懂,还有许多不懂的地方,欢迎大家交流.参考我的博文:http://blog.csdn.net/qq_33764491/article/details/78831010
3.抛弃cxf默认的log方式,使用log4j的方式,方便以后整合到其他app中而不改变之前系统log的方式。 答谢: 关于cxf的深入研究,我发现国人翻译的东西很少,我想尽自己的微薄之力能给大家带些有用的东西,如果有什么...
cxf 所有jar 和环境配置详细说明,一看就会好运行环境
使用CXF开发Web Service,包含服务器端和客户端
Maven坐标:org.apache.cxf:cxf-core:3.0.1; 标签:cxf、core、apache、jar包、java、API文档、中文版; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中...
搭建Webservice框架必备的jar包,方便快速搭建,ClientProxyFactoryBean JaxWsDynamicClientFactory 等工具类