求一个cxf+spring的例子,要能通

解决方案 »

  1.   

    到官网下载CXF软件
    http://cxf.apache.org/download.html
    解压后,有个samples\java_first_pojo目录,其中就是一个最简单的例子。
    项目用Maven可以构建。
      

  2.   

    给你个cxf调用webService的例子看看webservice启动配置如下
    <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">

    <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" />
    <jaxws:endpoint id="sqlExecuteService"
    implementor="com.unicom.uniformdata.SqlExecuteServiceImpl"
    address="/DesServer">
    </jaxws:endpoint>
    </beans>
      

  3.   

    web.xml<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>/services/*</url-pattern>
    </servlet-mapping><context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>WEB-INF/beans.xml</param-value>
    </context-param>
    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
      

  4.   

    servicepackage com.iflysse.cxf;
    import javax.jws.WebService;
    @WebService
    public class Vote implements IVote {
    private static int pointTotal;
    private static int userTotal;
    public int getVotePointTotal() {
    return pointTotal;
    }
    public int getVoteUserTotal() {
    return userTotal;
    }
    public boolean vote(String username, int point) {
    userTotal++;
    pointTotal+=point;
    return true;
    }
    }
    网上搜的,自己去看看
    http://www.iteye.com/topic/417208
      

  5.   

    哥有现成的demo(工程、war包、步骤文档),给邮箱发给你