Apache CXF 框架介绍,以及实现JAXWS和JSXRS规范的webservice服务

Apache CXF 框架介绍

Apache CXF =  Celtix + XFire, ApacheCXF 的前身叫做Apache CeltiXfire,现在已经正式更名为Apache CXF了,CXF继承了Celtix 和XFire两大开源项目的精华,提供了对JAX-WS 全面的支持,并且提供了多种Binding、DataBing、Tramsport 以及各种对Format 的支持,并且可以根据实际项目的需要,采用代码有限 (Code First)或者 WSDL 优先(WSDL First) 来轻松实现WebServices 的发布和使用,目前它仍只是Apache 的一个孵化项目。

Apache CXF  是一个开源的 Services 框架,CXF 帮助您利用 Frontend 编程API 来构建和开发 Service,像JAX-WS,这些Services 可以支持多种协议,比如:SOAP、XML/HTTP、RESTful 或者CORBA,并且可以在多种传输协议上运行,比如: HTTP、JMS 或者JBI,CXF 大大简化了Services 的创建,同时它继承了XFire 传统,一样可以天然地和Spring 进行无缝集成。

功能特性

CXF 包含了大量的功能特性,但是主要集中在以下几个方面:

(1)支持webServices 标准,包含SOAP、Basic Profile 、WS=addressing、WS-Policy、WS-ReableMessaging 和WS-Security。

(2)Frontends:CXF支持多种 Frontend 编程模型,CXF 实现了JAX-WS API (遵循JAX-WS 2.0 TCK版本),它包含一个“simple frontend”允许客户端和EndPoint 的创建,而不需要Annotation 注解,CXF 即支持WSDL 优先开发,也支持从Java 的代码优先开发模式。

(3)容易使用:CXF 设计的更加直观与容易使用,有大量简单的API 来快速构建代码优先的Services 各种Maven 的插件也使得集成更加容易,支持JAX-WS API 支持Spring2.0更加简化的XML 配置方式,等等。

实现JAXWS

<?xml version="1.0" encoding="UTF-8"?>

<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.demo</groupId>
  <artifactId>jaxws_service</artifactId>
  <version>1.0-SNAPSHOT</version>

  <name>jaxws_service</name>
  <!-- FIXME change it to the project's website -->
  <url>http://www.example.com</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
    <!---jaxws-->
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-frontend-jaxws</artifactId>
      <version>3.3.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-transports-http-jetty</artifactId>
      <version>3.1.6</version>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>1.7.25</version>
    </dependency>
  </dependencies>
  <build>
    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
      <plugins>
        <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
        
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值