1 下载CXF文件
apache官方网下载apache-cxf-2.2.2,地址:http://cxf.apache.org/
2 学习视频教程
2.1 视频
Iteye网站上的视频教程,可以下载学习使用
http://www.iteye.com/topic/305642
3 CXF与Spring集成配置重点分析
3.1 application.xml中的重要代码
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" 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://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <!—注意上面标签配置与常规spring的不同--> <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="helloWorld" mplementor="server.HelloWorldImpl" address="/helloWorld" /> </beans>
|
3.2 web.xml中的重要代码
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <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>/services/*</url-pattern> </servlet-mapping> <!—注意上面标签配置加入了/services/*配置,如果项目中还用到过滤器,就要注意把它的路径也也忽略掉--> </web-app> |
其他资料网络上很多,就不再一一列举,我写的就是我的经验,为了在实际项目中配对,也走了一些弯路,希望分享给大家,能给大家一定的帮助。