zoukankan      html  css  js  c++  java
  • CXF集成spring做webservice接口

      一 . cxf 的jar包

      1.cxf-2.3.3.jar

      2.wsdl4j-1.6.2.jar

      3.wss4j-1.5.11.jar

      4.wstx-asl-3.2.0.jar

      5.XmlSchema-1.4.7.jar

      以上没有spring和cxf的依赖包后续更新

    二. web.xml

    <!-- cxf servlet -->
        <servlet>
            <servlet-name>CXFservlet</servlet-name>
            <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>CXFservlet</servlet-name>
            <url-pattern>/webservice/*</url-pattern>
        </servlet-mapping>

    三.applicationContext.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"
        xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
        xmlns:cxf="http://cxf.apache.org/core"
        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
                 http://cxf.apache.org/transports/http/configuration
                 http://cxf.apache.org/schemas/configuration/http-conf.xsd http://cxf.apache.org/core 
                 http://cxf.apache.org/schemas/core.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" />
        
        <!-- 同步用户 -->
        <bean id="synchronousUserImpl" class="cn.chinaunicom.pmis.interfaces.sso.server.impl.SynchronousUserImpl"></bean>
        <jaxws:endpoint id="synchronousUser" implementor="#synchronousUserImpl" address="/synchronousUser"/>
    </beans>

    四.接口

    import javax.jws.WebService;
    
    /**
     * 同步用户webService
     * @author duwenlei
     *
     */
    @WebService
    public interface SynchronousUser {
        /**
         * 同步用户
         * @param json
         * @return
         */
        boolean syncUser(String json);
    }

    五.接口实现

    import javax.jws.WebService;
    
    import cn.chinaunicom.pmis.interfaces.sso.server.SynchronousUser;
    
    @WebService(endpointInterface="cn.chinaunicom.pmis.interfaces.sso.server.SynchronousUser")
    public class SynchronousUserImpl implements SynchronousUser {
    
        @Override
        public boolean syncUser(String json) {
            System.err.println("success");
            return false;
        }
    
    }

    六 . 运行tomcat

    访问 http://localhost:8080/pmisx/webservice/synchronousUser?wsdl 成功则cxf部署成功

    未完待续

  • 相关阅读:
    Java之List使用方法
    Java之数组遍历
    收集关于前端的一些网站、博客资源、框架、源码等 、 会持续更新哦!!!!!
    css常用代码含义
    css两列等高布局
    HTML之DocType的几种类型
    CSS实现圆角的方法
    IE6图片元素img下出现多余空白问题
    web标准常见问题整理
    好的 Web 前端年薪会有多少?
  • 原文地址:https://www.cnblogs.com/duwenlei/p/4953409.html
Copyright © 2011-2022 走看看