PA165/Lab session Webservices REST

Z FI WIKI
Verze z 25. 11. 2013, 16:01; 232464@muni.cz (diskuse | příspěvky)

(rozdíl) ← Starší verze | zobrazit aktuální verzi (rozdíl) | Novější verze → (rozdíl)
Přejít na: navigace, hledání


Developing RESTful webservices with Jersey

During this lab we will see how to create, and access a REST webservice by using the Jersey framework ([1]). Jersey provides support for JAX-RS APIs, providing further functionalities to simplify the development of RESTful webservices.

Just as a reminder, REpresentational State Transfer (REST) is defined as a set of architectural patterns that design web services based on resources. A RESTful webservice (compliant to REST principles) has the following characteristics:

  • Uses HTTP methods explicitly
  • Is stateless
  • It exposes URIs as directory structures to manage resources
  • Allows the transferral of XML and/or JavaScript Object Notation (JSON) formats


What is needed for the current lab:

Create a new project of type Maven - Web Application, named rest-jersey-server configured to be run under Tomcat. Add to the pom.xml file:


 
<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>
 
    <dependencies>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <!-- if your container implements Servlet API older than 3.0, use "jersey-container-servlet-core"  -->
            <artifactId>jersey-container-servlet</artifactId>
            <version>2.4.1</version>
        </dependency>
        <!-- Required only when you are using JAX-RS Client -->
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <version>2.4.1</version>
        </dependency>
     </dependencies>
    <build>
        <plugins>
            <!-- Java language version -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>6</source>
                    <target>6</target>
                </configuration>
            </plugin>
            <!-- Servlet 3.0 without web.xml -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
        </plugins>
    </build>
 
}

test