首页 > Web开发 > 详细

maven+spring3+cxf 搭建webservice服务

时间:2014-03-05 20:07:17      阅读:533      评论:0      收藏:0      [点我收藏+]


1.web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  <display-name>activiti</display-name>
    <!-- 设置Spring容器加载配置文件路径 -->  
    <context-param>  
        <param-name>contextConfigLocation</param-name>  
        <param-value>classpath:applicationContext.xml,classpath:applicationContext-activiti.xml</param-value>  
    </context-param>  
    <listener>  
        <listener-class>org.springframework.web.context.ContextLoaderListener</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>/webservices/*</url-pattern>  
    </servlet-mapping>  
 
</web-app>

2.

<?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:context="http://www.springframework.org/schema/context"
	xmlns:cache="http://www.springframework.org/schema/cache" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:jaxws="http://cxf.apache.org/jaxws"   
    xmlns:cxf="http://cxf.apache.org/core"
	xsi:schemaLocation="
          http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
          http://www.springframework.org/schema/tx
          http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
          http://www.springframework.org/schema/context
          http://www.springframework.org/schema/context/spring-context-3.1.xsd
          http://www.springframework.org/schema/aop
          http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
          http://www.springframework.org/schema/cache
          http://www.springframework.org/schema/cache/spring-cache-3.1.xsd
          http://cxf.apache.org/jaxws   
	      http://cxf.apache.org/schemas/jaxws.xsd   
	      http://cxf.apache.org/core   
	      http://cxf.apache.org/schemas/core.xsd">
	<!-- 下面3个配置文件,是CXF自带的配置文件,引入即可这里不做详解 -->
   <import resource="classpath:META-INF/cxf/cxf.xml" />        
   <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />        
   <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
	
	<jaxws:endpoint id="processServcie" implementor="com.boco.eoms.process.activiti.service.ProcessSheetService" 
		address="/processSheetService">
	</jaxws:endpoint>  

3.创建接口

@WebService
public interface ProcessService {
	/**
	 * 创建流程
	 */
	public String triggerProcess(@WebParam(name = "userId") String userId, @WebParam(name = "password")String password,
			@WebParam(name = "processTemplateName")String processTemplateName, 
			@WebParam(name = "operationName")String operationName, @WebParam(name = "triggerProcessData")TriggerProcessData triggerProcessData);

4.实现类

@WebService(endpointInterface="com.boco.eoms.process.activiti.service.ProcessService")
public class ProcessSheetService implements ProcessService {
5.pom.xml增加

		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-frontend-jaxws</artifactId>
			<version>2.7.10</version>
		</dependency>
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-transports-http</artifactId>
			<version>2.7.10</version>
		</dependency>

6.把工程部署到tomcat,启动后,访问

http://127.0.0.1:8080/工程名/webservices/processSheetService?wsdl

如果访问成功,证明webservcie服务搭建成功

maven+spring3+cxf 搭建webservice服务,布布扣,bubuko.com

maven+spring3+cxf 搭建webservice服务

原文:http://blog.csdn.net/liuccc1/article/details/20548543

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!