Apache CXF: Hello World Web Service (1)

Source: Internet
Author: User

Apache's CXF has almost become the preferred class library for Building Web Services in the Java field, and it is indeed easy to use. Below we will give a brief introduction through several series of articles.

Of course, the first thing that comes to mind is the Hello World example. The examples used in this series of articles are Maven-based projects. The following is the content of my pom. xml file.

 
 
  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> 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.