Spring整合CXF步骤
Spring实现webService,
spring整合WebService
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
蕃薯耀 2015年9月28日 16:40:28 星期一
http://fanshuyao.iteye.com/
一、在web.xml配置CXFServlet
<servlet>
<servlet-name>cxf</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet> <servlet-mapping>
<servlet-name>cxf</servlet-name>
<url-pattern>/ws/*</url-pattern>
</servlet-mapping>
其中url-pattern不能配置为/ws/**
二、在web.xml配置ContextLoaderListener
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring.xml</param-value>
</context-param> <listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
三、在spring.xml配置jaxws命名(xmlns:jaxws="http://cxf.apache.org/jaxws")
<?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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
四、在spring.xml配置webService服务(serviceClass配置的是类,serviceBean配置的是bean)
<!--
请求地址为:http://localhost:8080/cxf2.7-spring/ws/person
wsdl地址为:http://localhost:8080/cxf2.7-spring/ws/person?wsdl
其中ws是在web.xml中CXFServlet配置的路径
-->
<jaxws:server address="/person" serviceClass="com.spring.cxf.service.Impl.PersonServiceImpl">
<!--
<jaxws:serviceBean>
<bean class="com.spring.cxf.service.Impl.PersonServiceImpl"></bean>
</jaxws:serviceBean>
-->
<jaxws:inInterceptors>
<bean class="org.apache.cxf.interceptor.LoggingInInterceptor"></bean>
</jaxws:inInterceptors>
<jaxws:outFaultInterceptors>
<bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"></bean>
</jaxws:outFaultInterceptors>
</jaxws:server>
五、在实现类中加@WebService注解,声明该类为webService服务
@WebService(name="cccc",serviceName="dddd")
@Service
public class PersonServiceImpl implements PersonService{ }
六、访问http://localhost:8080/cxf2.7-spring/ws/时,会把所有服务都列出来。
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
蕃薯耀 2015年9月28日 16:40:28 星期一
http://fanshuyao.iteye.com/