第一,maven依赖cfx框架的jar包。还有spring相关的包。注意版本冲突

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.lzh</groupId>
  <artifactId>webserviceT</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
   <properties>
        <cxf.version>2.2.3</cxf.version>
        <spring.version>4.1.3.RELEASE</spring.version>
     </properties>
  <dependencies>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>${cxf.version}</version>
    </dependency> 
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>${cxf.version}</version>
    </dependency>
        <!-- Jetty is needed if you're are not using the CXFServlet -->
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http-jetty</artifactId>
        <version>${cxf.version}</version>
    </dependency>




        <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-beans</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
                <version>${spring.version}</version>
            </dependency>
  </dependencies>


   <build>
    <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <encoding>UTF-8</encoding>
                </configuration>
        </plugin>
        </plugins>
  </build>
</project>

第二,配置web.xml

主要是配置spring的启动加载文件,还有cfx框架的一个类,这个类就是说从配置好的路径访问,交给那个类处理。知道就行了。

<?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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>webserviceT</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>

   <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        //这个是自定义的cfx配置文件
        <param-value>classpath:ws-beans-*.xml</param-value>
    </context-param>

    <servlet>  
     <servlet-name>cxf</servlet-name>  
     <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>  
     <load-on-startup>1</load-on-startup>  
 </servlet>  

 <servlet-mapping>  
     <servlet-name>cxf</servlet-name>  
     <url-pattern>/webservice/*</url-pattern>  
  </servlet-mapping>  
</web-app>

ws-beans-server.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:jaxws="http://cxf.apache.org/jaxws"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
                       http://www.springframework.org/schema/beans/spring-beans.xsd
                       http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
    <!--
        手动添加的内容:
        xmlns:jaxws="http://cxf.apache.org/jaxws"
        http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"
     -->
   //这三个是加载cfx的文件。必须写的。
    <import resource="classpath:META-INF/cxf/cxf.xml" />
    <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
//这个是配置你服务器对外暴露的接口,address就写个路径就行了,因为服务器原本就有ip和端口号,
implementor有两种,一个是直接写类名,一个是写一个bean,然后引用id,id前面加#,加拦截器
   <bean id="webServiceTestImpl" class="com.lzh.ws.WebServiceTestImpl"/>
    <jaxws:endpoint id="greetingService"  
        implementor="#webServiceTestImpl"   
        address="/GreetingService" >  
        <jaxws:inInterceptors>
            <bean class="com.lzh.ws.AuthInInterceptor"/>
        </jaxws:inInterceptors>
    </jaxws:endpoint>  

</beans>

这个就可以了。其实可简单。马丹 ,让我搞一天,就是因为jar包问题,总是启动不起来。哎。谨记!!!!!
访问 http://localhost:8080/webserviceT/webservice/GreetingService?wsdl