一:在web.xml中增加CXFServlet的配置:
<servlet> <description>Apache CXF Endpoint</description> <display-name>cxf</display-name> <servlet-name>cxf</servlet-name> <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>cxf</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping>
二:新建applicationContext-cxf.xml,配置endpoint ,url等信息
<?xml version="1.0" encoding="UTF-8"?> <!-- START SNIPPET: beans --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" 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"> <import resource="classpath:META-INF/cxf/cxf.xml"/> <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/> <jaxws:endpoint id="idssWervices" implementor="com.easylife.function.sample2.server.DssWebServicesImpl" address="/idssWervices"/> <jaxws:endpoint id="helloWorld" implementor="demo.spring.service.HelloWorldImpl" address="/HelloWorld"/> </beans> <!-- END SNIPPET: beans -->
根据spring contextConfigLocation加载规则,我们把applicationContext-cxf.xml放到classpath:config/context/下。
<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:config/context/applicationContext*.xml</param-value> </context-param>
三:测试
@WebService(endpointInterface = "com.easylife.function.sample2.webInterface.IdssWervices") public class DssWebServicesImpl implements IdssWervices { Map<Integer, User> users = new LinkedHashMap<Integer, User>(); @Autowired ChangeOutInServive changeOutInServive; public String sayHi(String text) { return "Hello " + text; } public String sayHiToUser(User user) { changeOutInServive.getBomPartCode(""); users.put(users.size()+1, user); return "Hello "+ user.getName(); }
@RequestMapping("/helloworld") public String test(Model model){ JaxWsProxyFactoryBean svr = new JaxWsProxyFactoryBean(); svr.setServiceClass(IdssWervices.class); svr.setAddress("http://localhost:8082/easylife/services/idssWervices"); IdssWervices hw = (IdssWervices) svr.create(); User user = new User(); user.setName("textYYh"); user.setDescription("test"); String response = hw.sayHiToUser(user); model.addAttribute("msg",response ); return "webservicetest"; }
经测试changeOutInServive 已经注入,和spring集成成功。
相关推荐
Apache cxf 与spring集成
用webservice中的xfire框架升级到cxf框架开发的实例,供大家分享~~~~
NULL 博文链接:https://ynp.iteye.com/blog/888547
cxf与spring集成 需要最少的jar如下: cxf-2.3.3.jar geronimo-annotation_1.0_spec-1.1.1.jar geronimo-jaxws_2.2_spec-1.0.jar geronimo-stax-api_1.0_spec-1.0.1.jar geronimo-ws-metadata_2.0_spec-1.1.3.jar ...
CXF集成Spring发布WebService代码实例
CXF跟Spring集成的 WebServer实例 由于大小限制 没有上传Jar包,Cxf版本为 apache-cxf-2.3.0 可以官网下载http://cxf.apache.org/
webService实现 cxf2.7.5 与 spring3.0集成 完整流程,内涵全部jar ,下载集合运行
CXF 集成 mybatis spring 环境搭建,以及开发所需要的CXF JAR 包
详细介绍Cxf集成与Spring 实现WebService.
cxf与spring整合webservice所需jar
cxf集成Spring的restful WebServ ice接口,Demo的完整代码!
Cxf集成Spring的WebService接口的配置文档
Spring是目前最流行的JavaEE Framework,但是使用Spring的Spring-WS开发WebService却...CXF是一个简化WebService开发的开源项目,通过Spring和CXF的结合可以大大简化基于Spring Framework的应用中的WebService开发。
cxf-2.2.9.jar geronimo-javamail_1.4_spec-1.7.1.jar geronimo-jaxws_2.2_spec-1.1.jar geronimo-jms_1.1_spec-1.1.1.jar geronimo-servlet_3.0_spec-1.0.jar jaxb-api-2.2.6.jar jaxb-impl-2.2.6.jar neethi-3.0.1...
cxf+spring+hibernate集成整合jar包
该项目展示了如何使用纯 Java 配置将 CXF Apache JAX-WS 实现与 Spring 集成的简单示例。 建造 mvn clean verify 配置 JavaConfiguration或XMLConfiguration可以与CXFServletConfiguration一起单独运行。 此配置...
自己在用的接口框架,实现了CXF和spring和hibernate的集成
自己总结的一个CXF集成Spring的例子,可以直接运行,附源码! 程序的详细说明请参照博客文档 http://blog.csdn.net/sunbaojin5213344/article/details/8931600
CXF与Spring整合的入门案列 这是服务器端的案列 已经优化到最小的lib包
CXF2.5.0+Spring2.5 集成DEMO