maven+spring3+cxf 搭建webservice服务



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服务搭建成功

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值