程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> JAVA編程 >> J2EE >> Apache CXF實戰之一:Hello World Web Service(1)

Apache CXF實戰之一:Hello World Web Service(1)

編輯:J2EE

apache的CXF現在幾乎成了Java領域構建Web Service的首選類庫,並且它也確實簡單易用,下面就通過幾篇系列文章做一下簡單介紹。

當然首先想到的當然還是那個Hello World示例。這個系列文章中用到的例子都是基於Maven構建的工程,下面是我的pom.XML文件內容

  1. <project XMLns="http://maven.apache.org/POM/4.0.0" XMLns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  2.     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">  
  3.     <modelVersion>4.0.0</modelVersion>  
  4.     <groupId>com.googlecode.garbagecan.cxfstudy</groupId>  
  5.     <artifactId>cxfstudy</artifactId>  
  6.     <packaging>war</packaging>  
  7.     <version>1.0-SNAPSHOT</version>  
  8.     <name>cxfstudy Maven Webapp</name>  
  9.     <url>http://maven.apache.org</url>  
  10.       
  11.     <propertIEs>  
  12.         <cxf.version>2.2.7</cxf.version>  
  13.     </propertIEs>  
  14.       
  15.     <dependencIEs>  
  16.         <dependency>  
  17.             <groupId>org.apache.cxf</groupId>  
  18.             <artifactId>cxf-rt-frontend-jaxws</artifactId>  
  19.             <version>${cxf.version}</version>  
  20.         </dependency>  
  21.         <dependency>  
  22.             <groupId>org.apache.cxf</groupId>  
  23.             <artifactId>cxf-rt-transports-http</artifactId>  
  24.             <version>${cxf.version}</version>  
  25.         </dependency>  
  26.         <dependency>  
  27.             <groupId>org.apache.cxf</groupId>  
  28.             <artifactId>cxf-rt-transports-http-jetty</artifactId>  
  29.             <version>${cxf.version}</version>  
  30.         </dependency>  
  31.         <dependency>  
  32.             <groupId>org.apache.cxf</groupId>  
  33.             <artifactId>cxf-rt-ws-security</artifactId>  
  34.             <version>${cxf.version}</version>  
  35.         </dependency>  
  36.         <dependency>  
  37.             <groupId>org.apache.cxf</groupId>  
  38.             <artifactId>cxf-rt-ws-policy</artifactId>  
  39.             <version>${cxf.version}</version>  
  40.         </dependency>  
  41.         <dependency>  
  42.             <groupId>org.apache.cxf</groupId>  
  43.             <artifactId>cxf-bundle-jaxrs</artifactId>  
  44.             <version>${cxf.version}</version>  
  45.         </dependency>  
  46.         <dependency>  
  47.             <groupId>Javax.ws.rs</groupId>  
  48.             <artifactId>JSr311-api</artifactId>  
  49.             <version>1.1.1</version>  
  50.         </dependency>  
  51.         <dependency>  
  52.             <groupId>org.slf4j</groupId>  
  53.             <artifactId>slf4j-api</artifactId>  
  54.             <version>1.5.8</version>  
  55.         </dependency>  
  56.         <dependency>  
  57.             <groupId>org.slf4j</groupId>  
  58.             <artifactId>slf4j-jdk14</artifactId>  
  59.             <version>1.5.8</version>  
  60.         </dependency>  
  61.         <dependency>  
  62.             <groupId>commons-httpclIEnt</groupId>  
  63.             <artifactId>commons-httpclIEnt</artifactId>  
  64.             <version>3.0</version>  
  65.         </dependency>  
  66.         <dependency>  
  67.             <groupId>commons-io</groupId>  
  68.             <artifactId>commons-io</artifactId>  
  69.             <version>1.4</version>  
  70.         </dependency>  
  71.         <dependency>  
  72.             <groupId>junit</groupId>  
  73.             <artifactId>junit</artifactId>  
  74.             <version>4.8.1</version>  
  75.             <scope>test</scope>  
  76.         </dependency>  
  77.     </dependencIEs>  
  78.       
  79.     <build>  
  80.         <finalName>cxfstudy</finalName>  
  81.         <resources>  
  82.             <resource>  
  83.                 <directory>src/main/resources</directory>  
  84.             </resource>  
  85.             <resource>  
  86.                 <directory>src/main/Java</directory>  
  87.                 <includes>  
  88.                     <include>**</include>  
  89.                 </includes>  
  90.                 <excludes>  
  91.                     <exclude>**/*.Java</exclude>  
  92.                 </excludes>  
  93.             </resource>  
  94.         </resources>  
  95.         <plugins>  
  96.             <plugin>  
  97.                 <groupId>org.mortbay.jetty</groupId>  
  98.                 <artifactId>maven-jetty-plugin</artifactId>  
  99.                 <configuration>  
  100.                     <contextPath>/</contextPath>  
  101.                     <connectors>  
  102.                         <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">  
  103.                             <port>9000</port>  
  104.                         </connector>  
  105.                     </connectors>  
  106.                 </configuration>  
  107.             </plugin>  
  108.             <plugin>  
  109.                 <groupId>org.apache.maven.plugins</groupId>  
  110.                 <artifactId>maven-compiler-plugin</artifactId>  
  111.                 <configuration>  
  112.                     <source>1.5</source>  
  113.                     <target>1.5</target>  
  114.                 </configuration>  
  115.             </plugin>  
  116.         </plugins>  
  117.     </build>  
  118.  
  119. </project> 

1 2 下一頁>> 內容導航  第 1 頁:pom.XML文件內容  第 2 頁:HelloWorld的具體例子
  • 給力(2票)
  • 動心(2票)
  • 廢話(4票)
  • 專業(2票)
  • 標題黨(2票)
  • 路過(2票)

原文:apache CXF實戰之一:Hello World Web Service(1) 返回開發首頁
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved