首页 > 代码库 > spring与CXF整合配置(服务端)
spring与CXF整合配置(服务端)
web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>CXF</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> //用于处理CXF请求
</servlet>
<servlet-mapping>
<servlet-name>CXF</servlet-name>
<url-pattern>/CXF/*</url-pattern>
</servlet-mapping>
applicationContext.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:jaxws="http://cxf.apache.org/jaxws"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.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-extension-soap.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
//发布服务配置
<jaxws:endpoint implementor="impl.HelloWorldImpl" //暴露接口的实现类
address="/Hello" >//表示入口
<jaxws:inInterceptors>
<bean class="util.AuthInInterceptor"/>//自定义的CXF拦截器
</jaxws:inInterceptors>
通过:http://localhost:8080//CXF_Spring/CXF/Hello?wsdl 就可以访问到wsdl文件
spring与CXF整合配置(服务端)