posts - 122,  comments - 25,  trackbacks - 0
          Apache CXF 則是由 Celtix 和 XFire 項(xiàng)目整合而生,并且剛剛發(fā)布了 2.0.2 的最新版本,不過仍是 Apache 的一個孵化項(xiàng)目。

          一、與Axis2的不同之處
            1、Apache CXF 支持 WS-Addressing、WS-Policy、WS-RM、WS-Security和WS-I BasicProfile
            2、Axis2 支持 WS-Addressing、WS-RM、WS-Security和WS-I BasicProfile,WS-Policy將在新版本里得到支持
            3、Apache CXF 是根據(jù)Spring哲學(xué)來進(jìn)行編寫的,即可以無縫地與Spring進(jìn)行整合
            4、Axis2 不是
            5、Axis2 支持更多的 data bindings,包括 XMLBeans、JiBX、JaxMe 和 JaxBRI,以及它原生的 data binding(ADB)。
            6、Apache CXF 目前僅支持 JAXB 和 Aegis,并且默認(rèn)是 JAXB 2.0,與 XFire 默認(rèn)是支持 Aegis 不同,XMLBeans、JiBX 和 Castor 將在 CXF 2.1 版本中得到支持,目前版本是 2.0.2
            7、Axis2 支持多種語言,它有 C/C++ 版本。
            8、Apache CXF 提供方便的Spring整合方法,可以通過注解、Spring標(biāo)簽式配置來暴露Web Services和消費(fèi)Web Services

          二、A simple JAX-WS service
          原文見http://cwiki.apache.org/CXF20DOC/a-simple-jax-ws-service.html

          a). 設(shè)置構(gòu)建路徑,將下列jar包放到項(xiàng)目中
          the CXF distribution
          commons-logging-1.1.jar
          geronimo-activation_1.1_spec-1.0-M1.jar (or Sun's Activation jar)
          geronimo-annotation_1.0_spec-1.1.jar (JSR 250)
          geronimo-javamail_1.4_spec-1.0-M1.jar (or Sun's JavaMail jar)
          geronimo-servlet_2.5_spec-1.1-M1.jar (or Sun's Servlet jar)
          geronimo-ws-metadata_2.0_spec-1.1.1.jar (JSR 181)
          jaxb-api-2.0.jar
          jaxb-impl-2.0.5.jar
          jaxws-api-2.0.jar
          jetty-6.1.5.jar
          jetty-util-6.1.5.jar
          neethi-2.0.jar
          saaj-api-1.3.jar
          saaj-impl-1.3.jar
          stax-api-1.0.1.jar
          wsdl4j-1.6.1.jar
          wstx-asl-3.2.1.jar
          XmlSchema-1.2.jar
          xml-resolver-1.2.jar

          Spring jars
          aopalliance-1.0.jar
          spring-core-2.0.4.jar
          spring-beans-2.0.4.jar
          spring-context-2.0.4.jar
          spring-web-2.0.4.jar

          CXF jar
          cxf-2.0-incubator.jar

          b). 編寫Service代碼
          接口HelloService.java
          package demo.cxf.server;

          import javax.jws.WebParam;
          import javax.jws.WebService;

          @WebService
          public interface HelloService {

              
          public String sayHello(@WebParam(name="text")String text);
          }

          實(shí)現(xiàn)類HelloServiceImpl
          package demo.cxf.server;

          import javax.jws.WebService;

          @WebService(endpointInterface
          ="demo.cxf.server.HelloService",serviceName="helloService")
          public class HelloServiceImpl implements HelloService {
              
              
          public String sayHello(String text) {
                  
          return "Hello ".concat(text);
              }


          }

          c). 發(fā)布服務(wù)
                  System.out.println("Starting Server");
                  HelloServiceImpl impl 
          = new HelloServiceImpl();
                  String addr 
          = "http://localhost:80/helloService";
                  Endpoint.publish(addr,impl);

          d). 客戶端調(diào)用
                  JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
                  factory.getInInterceptors().add(
          new LoggingInInterceptor());
                  factory.getOutInterceptors().add(
          new LoggingOutInterceptor());
                  factory.setServiceClass(HelloService.
          class);
                  factory.setAddress(
          "http://localhost:9000/helloService");
                  HelloService service 
          = (HelloService)factory.create();
                  
                  String reply 
          = service.sayHello("cxf.");
                  System.out.println(reply);
                  System.exit(
          0);
          posted on 2007-11-21 23:01 josson 閱讀(1004) 評論(0)  編輯  收藏 所屬分類: java 開發(fā)
          <2007年11月>
          28293031123
          45678910
          11121314151617
          18192021222324
          2526272829301
          2345678

          常用鏈接

          留言簿(3)

          隨筆分類

          隨筆檔案

          收藏夾

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 庆云县| 黄骅市| 奎屯市| 台北市| 德化县| 红安县| 林周县| 宜州市| 兴宁市| 西昌市| 上饶市| 大安市| 石景山区| 壤塘县| 乡宁县| 五指山市| 太和县| 洛南县| 乐清市| 皋兰县| 伊春市| 越西县| 沙河市| 曲麻莱县| 漳浦县| 绵竹市| 保山市| 容城县| 巨鹿县| 正镶白旗| 黄冈市| 汨罗市| 衡山县| 海口市| 喜德县| 郯城县| 海盐县| 藁城市| 喀什市| 资中县| 德化县|