一.环境准备  

  1. 安装eclipse  

  2. 安装jdk1.8

  3.配置maven

  4.安装tomcat

二、构建webservice工程

1.创建maven webapp工程

maven构建spring+cxf的webservice工程_第1张图片

maven构建spring+cxf的webservice工程_第2张图片

2.build path 为jdk1.8

maven构建spring+cxf的webservice工程_第3张图片

3.配置maven 工程依赖pom.xml文件


        
      junit
      junit
      3.8.1
      test
    
   
        
            org.springframework
            spring-context
            4.3.0.RELEASE
        
        
            org.springframework
            spring-orm
            4.3.0.RELEASE
        
        
            org.springframework
            spring-web
            4.3.0.RELEASE
        
        
            org.springframework
            spring-webmvc
            4.3.0.RELEASE
        
        
            org.springframework.security
            spring-security-core
            4.2.1.RELEASE
        
        
            org.springframework.security
            spring-security-web
            4.2.1.RELEASE
        
        
            org.springframework.security
            spring-security-config
            4.2.1.RELEASE
        
        
            org.springframework.security
            spring-security-ldap
            4.2.1.RELEASE
        
        
            org.springframework.security
            spring-security-acl
            4.2.1.RELEASE
        
        
            org.springframework.security
            spring-security-cas
            4.2.1.RELEASE
        
        
            org.springframework.security
            spring-security-taglibs
            4.2.1.RELEASE
        
        
         org.springframework
       spring-aop
       4.3.0.RELEASE
       
        
        
        org.springframework
        spring-beans
        4.3.0.RELEASE
       
       
       
    org.springframework
    spring-aspects
    4.3.0.RELEASE
    
       
        
        
            org.springframework
            spring-test
            4.3.0.RELEASE
        
        
      org.springframework
      spring-context-support
      4.3.0.RELEASE
      
      
    
    org.springframework
    spring-instrument
    4.3.0.RELEASE
    
    
    
    org.springframework
    spring-core
    4.3.0.RELEASE
 
      
    
       
   commons-logging
   commons-logging
   1.2
  
  
   org.slf4j
   slf4j-log4j12
   1.6.6
  

  
    
            org.apache.cxf  
            cxf-rt-frontend-jaxws  
            3.0.10  
          
        
        
     
    
 
    
       org.aspectj
       aspectjweaver
       1.8.9
    
        
  

4.创建webservice发布的接口和实现类

接口类

package com.test;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
@WebService
@SOAPBinding(style = Style.RPC)
public interface IServ {
@WebMethod
public String sayHi(@WebParam(name = "param") String param);
}

实现类

package com.test.impl;
import com.test.IServ;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
@WebService(endpointInterface = "com.test.IServ")
@SOAPBinding(style = Style.RPC)
public class IServImpl implements IServ {
 public String sayHi(@WebParam(name = "param") String param) {
  // TODO Auto-generated method stub
  return "hello" + param;
 }
}

5.配置web.xml



 
 
 
  contextConfigLocation
  classpath:application-server.xml
 
 
 
  encoding
  org.springframework.web.filter.CharacterEncodingFilter
  
   encoding
   UTF-8
  
 
 
  encoding
  /*
 
 
 
 
  org.springframework.web.context.ContextLoaderListener
 
   
 
  CXFServlet
  org.apache.cxf.transport.servlet.CXFServlet
  1
 
 
  CXFServlet
  /*
 
 
  index.jsp
 


6.配置spring + websevice 发布配置文件 application-server.xml




 
  
   
   
  
 

7.部署到tomcat,publish webservice

maven构建spring+cxf的webservice工程_第4张图片

看到下图就说明该webservice发布成功

maven构建spring+cxf的webservice工程_第5张图片

maven构建spring+cxf的webservice工程_第6张图片