cxf+spring 服务器端

it2022-05-05  64

一、首先,CXF和spring整合需要准备如下jar包文件:

 

二、WEB-INF下配置web.xml

<!-- 加载Spring容器配置 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 设置Spring容器加载配置文件路径 ,注入配置 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:applicationContext.xml</param-value> </context-param> <---配置监听器, 当 发起 工程名+webSer 的请求时 --> <listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> <servlet> <servlet-name>CXFService</servlet-name> <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>CXFService</servlet-name> <url-pattern>/webSer/*</url-pattern> </servlet-mapping>三、配置 spring 配置文件 固定

<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-extension-soap.xml" /> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

<!-- userService为接口(@webService)     UserServiceImpl 为实现类,即配置 实现类的bean --> <bean id="userSer" class="com.cvicse.service.impl.UserServiceImpl"></bean>

<!-- address  为  访问 wsdl地址,即 工程名+webSer(拦截)+serch .wsdl --> <jaxws:endpoint id="userService" implementor="#userSer" address="/serch"></jaxws:endpoint></beans>

转载于:https://www.cnblogs.com/li-xy/p/4244096.html


最新回复(0)