记SpringMVC整合cxf发布webservices服务【留档】
记SpringMVC整合cxf发布webservices服务【留档】
网络查询的发现大部分有遗漏不全,或不可用。整合多个后才成功,在这留个档记录下。
1.所需jar包 :jar包链接
也可以网上找
2、代码 添加
接口:
接口实现类
3、配置
修改web.xml文件,在末尾增加配置<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>/webservice/*</url-pattern> </servlet-mapping>
新增spring-cxf.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:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
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://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd" >
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<!-- 注意:serviceClass为接口类并非实现类 -->
<jaxws:server serviceClass="com.just.soft.webservice.IWebService" address="/process"></jaxws:server>
</beans>
在web.xml中引入spring-cxf.xml文件(地址以实际地址为准)
然后可以启动了
访问地址:http://localhost:8080/Xxxx/webservice/process?wsdl