SlideShare una empresa de Scribd logo
1 de 16
Group15 Rest
    Yuan Gao
    Ning Ma
     Bin Cai
Overview
Introduction

Technologies and toolkits

Architecture

Implementation & Security

Deploy & Test

Analysis and evaluation
Introduction

RESTful Web Services is different from SOAP-
style services

using HTTP GET PUT POST DELETE

Unique URI to describe Resource
Introduction
Client

3 Services:
TravelAgent, Flight, Hotel

Resources:
/flight
/hotel
/booking
/query
Technologies and
     Toolkits

AJAX: send request and receive response

XML: store and transmit data

JAX-RS (JSR 311): Java API for RESTful Web
Services
Technologies and
     Toolkits

Maven: project management

Jersey: JAX-RS Reference Implementation for
building RESTful Web services

Grizzly: Web application container
Architecture
  Diagram
Implementation
     define classes:
import                                      import
javax.xml.bind.annotation.XmlRootElement;   javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement                             @XmlRootElement
public class Flight {                       public class Hotel {
!                                           !   private int Id;
!   private int flightNo;                    !   private String Name;
!   private String from;                    !   private int price;
!   private String to;                      !   private String address;
!   private int departTime;                 !   public Hotel() {}
!   private int arriveTime;                 ...
!   private int price;
!   public Flight() {}
...
     TravelAgent, FlightResource, HotelResource...etc...
Implementation

Jersey API annotation:
@Path
@GET
@POST
@Produces
...

Let’s look at some pieces of code as example:
Some code...
@Path("/flight")
@Produces("application/xml")
public class FlightResource {
!
!   public TreeMap<Integer, Flight> flightMap = new TreeMap<Integer, Flight>();

    ...

!    @GET
!    public List<Flight> getFlights() {
!      List<Flight> flights = new ArrayList<Flight>();
!      flights.addAll(getFlightMap().values());
!      return flights;
!    }
Some code...

...

      @GET
!     @Path("{flightNo}")
!     public Flight getFlight(@PathParam("flightNo") int cId) {
!       return getFlightMap().get(cId);
!     }
...
Security

HTTPS: use class HTTPSProperties to set
javax.net.ssl.HostnameVerifier and
javax.net.ssl.SSLContext

@Context SecurityContext customer

if (customer.isUserInRole("user") {
           return new Flight();
        } else {
           return “please provide effective customer”;
      }
Deploy
<web-app>
 <servlet>
 <servlet-name>Jersey Web Application</servlet-name>
 <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
  <init-param>
   <param-name>com.sun.jersey.config.property.packages</param-name>
   <param-value>uk.ac.soton.ecs.comp6017</param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
 <servlet-name>Jersey Web Application</servlet-name>
 <url-pattern>/*</url-pattern>
 </servlet-mapping>
</web-app>
Test
          use Jersey client api to set up test case

try {
   ! !    System.out.println("==> Test 1: Get all flight ");
      !
   ! !    ClientConfig config = new DefaultClientConfig();
   ! !    Client client = Client.create(config);
   ! !    client.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, true);
   ! !    WebResource service = client.resource("http://localhost:8080/");

System.out.println(service.path("rest2011").path("travelagent").type(MediaType.APPLICATION_FORM_
URLENCODED).get(String.class));
      System.out.println("n");
  ! }


...
Analysis and
       evaluation

Understanding REST architecture

Use toolkits to implement scenario

Challenges

Work as a team
Thank you!

Más contenido relacionado

La actualidad más candente

Interoperable Web Services with JAX-WS
Interoperable Web Services with JAX-WSInteroperable Web Services with JAX-WS
Interoperable Web Services with JAX-WSCarol McDonald
 
Symfony2, Backbone.js &amp; socket.io - SfLive Paris 2k13 - Wisembly
Symfony2, Backbone.js &amp; socket.io - SfLive Paris 2k13 - WisemblySymfony2, Backbone.js &amp; socket.io - SfLive Paris 2k13 - Wisembly
Symfony2, Backbone.js &amp; socket.io - SfLive Paris 2k13 - WisemblyGuillaume POTIER
 
Angular 4 for Java Developers
Angular 4 for Java DevelopersAngular 4 for Java Developers
Angular 4 for Java DevelopersYakov Fain
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedBG Java EE Course
 
Using Java to implement SOAP Web Services: JAX-WS
Using Java to implement SOAP Web Services: JAX-WS�Using Java to implement SOAP Web Services: JAX-WS�
Using Java to implement SOAP Web Services: JAX-WSKatrien Verbert
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Eliran Eliassy
 
Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)Oro Inc.
 
Working with oro crm entities
Working with oro crm entitiesWorking with oro crm entities
Working with oro crm entitiesOro Inc.
 
OroCRM Partner Technical Training: September 2015
OroCRM Partner Technical Training: September 2015OroCRM Partner Technical Training: September 2015
OroCRM Partner Technical Training: September 2015Oro Inc.
 
Resting with OroCRM Webinar
Resting with OroCRM WebinarResting with OroCRM Webinar
Resting with OroCRM WebinarOro Inc.
 
Workshop 2: JavaScript Design Patterns
Workshop 2: JavaScript Design PatternsWorkshop 2: JavaScript Design Patterns
Workshop 2: JavaScript Design PatternsVisual Engineering
 
Spring 3.x - Spring MVC
Spring 3.x - Spring MVCSpring 3.x - Spring MVC
Spring 3.x - Spring MVCGuy Nir
 
Java API for XML Web Services (JAX-WS)
Java API for XML Web Services (JAX-WS)Java API for XML Web Services (JAX-WS)
Java API for XML Web Services (JAX-WS)Peter R. Egli
 
Spring MVC Architecture Tutorial
Spring MVC Architecture TutorialSpring MVC Architecture Tutorial
Spring MVC Architecture TutorialJava Success Point
 
RESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP FrameworkRESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP FrameworkBo-Yi Wu
 

La actualidad más candente (20)

Spring Web MVC
Spring Web MVCSpring Web MVC
Spring Web MVC
 
Slim Framework
Slim FrameworkSlim Framework
Slim Framework
 
Interoperable Web Services with JAX-WS
Interoperable Web Services with JAX-WSInteroperable Web Services with JAX-WS
Interoperable Web Services with JAX-WS
 
Symfony2, Backbone.js &amp; socket.io - SfLive Paris 2k13 - Wisembly
Symfony2, Backbone.js &amp; socket.io - SfLive Paris 2k13 - WisemblySymfony2, Backbone.js &amp; socket.io - SfLive Paris 2k13 - Wisembly
Symfony2, Backbone.js &amp; socket.io - SfLive Paris 2k13 - Wisembly
 
Angular 4 for Java Developers
Angular 4 for Java DevelopersAngular 4 for Java Developers
Angular 4 for Java Developers
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advanced
 
Using Java to implement SOAP Web Services: JAX-WS
Using Java to implement SOAP Web Services: JAX-WS�Using Java to implement SOAP Web Services: JAX-WS�
Using Java to implement SOAP Web Services: JAX-WS
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics
 
JAX-WS Basics
JAX-WS BasicsJAX-WS Basics
JAX-WS Basics
 
Spring MVC 3.0 Framework (sesson_2)
Spring MVC 3.0 Framework (sesson_2)Spring MVC 3.0 Framework (sesson_2)
Spring MVC 3.0 Framework (sesson_2)
 
Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)
 
Working with oro crm entities
Working with oro crm entitiesWorking with oro crm entities
Working with oro crm entities
 
OroCRM Partner Technical Training: September 2015
OroCRM Partner Technical Training: September 2015OroCRM Partner Technical Training: September 2015
OroCRM Partner Technical Training: September 2015
 
Angular genericforms2
Angular genericforms2Angular genericforms2
Angular genericforms2
 
Resting with OroCRM Webinar
Resting with OroCRM WebinarResting with OroCRM Webinar
Resting with OroCRM Webinar
 
Workshop 2: JavaScript Design Patterns
Workshop 2: JavaScript Design PatternsWorkshop 2: JavaScript Design Patterns
Workshop 2: JavaScript Design Patterns
 
Spring 3.x - Spring MVC
Spring 3.x - Spring MVCSpring 3.x - Spring MVC
Spring 3.x - Spring MVC
 
Java API for XML Web Services (JAX-WS)
Java API for XML Web Services (JAX-WS)Java API for XML Web Services (JAX-WS)
Java API for XML Web Services (JAX-WS)
 
Spring MVC Architecture Tutorial
Spring MVC Architecture TutorialSpring MVC Architecture Tutorial
Spring MVC Architecture Tutorial
 
RESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP FrameworkRESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP Framework
 

Destacado

S: a Scripting Language for High-Performance RESTful Web Services
S: a Scripting Language for High-Performance RESTful Web ServicesS: a Scripting Language for High-Performance RESTful Web Services
S: a Scripting Language for High-Performance RESTful Web ServicesAchille Peternier
 
Servicii Web prin REST
Servicii Web prin RESTServicii Web prin REST
Servicii Web prin RESTSabin Buraga
 
Web services soap and rest by mandakini for TechGig
Web services soap and rest by mandakini for TechGigWeb services soap and rest by mandakini for TechGig
Web services soap and rest by mandakini for TechGigMandakini Kumari
 
Rest presentation
Rest  presentationRest  presentation
Rest presentationsrividhyau
 
Criando e consumindo webservice REST com PHP e JSON
Criando e consumindo webservice REST com PHP e JSONCriando e consumindo webservice REST com PHP e JSON
Criando e consumindo webservice REST com PHP e JSONMarcio Junior Vieira
 
Design Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIsDesign Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIsStormpath
 

Destacado (11)

S: a Scripting Language for High-Performance RESTful Web Services
S: a Scripting Language for High-Performance RESTful Web ServicesS: a Scripting Language for High-Performance RESTful Web Services
S: a Scripting Language for High-Performance RESTful Web Services
 
Servicii Web prin REST
Servicii Web prin RESTServicii Web prin REST
Servicii Web prin REST
 
Rest application
Rest applicationRest application
Rest application
 
Implementation advantages of rest
Implementation advantages of restImplementation advantages of rest
Implementation advantages of rest
 
Web services soap and rest by mandakini for TechGig
Web services soap and rest by mandakini for TechGigWeb services soap and rest by mandakini for TechGig
Web services soap and rest by mandakini for TechGig
 
Rest presentation
Rest  presentationRest  presentation
Rest presentation
 
REST Presentation
REST PresentationREST Presentation
REST Presentation
 
Criando e consumindo webservice REST com PHP e JSON
Criando e consumindo webservice REST com PHP e JSONCriando e consumindo webservice REST com PHP e JSON
Criando e consumindo webservice REST com PHP e JSON
 
RESTful Web Services
RESTful Web ServicesRESTful Web Services
RESTful Web Services
 
Design Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIsDesign Beautiful REST + JSON APIs
Design Beautiful REST + JSON APIs
 
JSON and REST
JSON and RESTJSON and REST
JSON and REST
 

Similar a Restful Web Service

Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018Loiane Groner
 
AWS re:Invent 2016: Chalice: A Serverless Microframework for Python (DEV308)
AWS re:Invent 2016: Chalice: A Serverless Microframework for Python (DEV308)AWS re:Invent 2016: Chalice: A Serverless Microframework for Python (DEV308)
AWS re:Invent 2016: Chalice: A Serverless Microframework for Python (DEV308)Amazon Web Services
 
Test-Driven Documentation for your REST(ful) service
Test-Driven Documentation for your REST(ful) serviceTest-Driven Documentation for your REST(ful) service
Test-Driven Documentation for your REST(ful) serviceJeroen Reijn
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSam Brannen
 
Web2Day 2017 - Concilier DomainDriveDesign et API REST
Web2Day 2017 - Concilier DomainDriveDesign et API RESTWeb2Day 2017 - Concilier DomainDriveDesign et API REST
Web2Day 2017 - Concilier DomainDriveDesign et API RESTNicolas Faugout
 
JavaOne Brasil 2016: JavaEE e HTML5: da web/desktop ao mobile
JavaOne Brasil 2016: JavaEE e HTML5: da web/desktop ao mobileJavaOne Brasil 2016: JavaEE e HTML5: da web/desktop ao mobile
JavaOne Brasil 2016: JavaEE e HTML5: da web/desktop ao mobileLoiane Groner
 
The battle of Protractor and Cypress - RunIT Conference 2019
The battle of Protractor and Cypress - RunIT Conference 2019The battle of Protractor and Cypress - RunIT Conference 2019
The battle of Protractor and Cypress - RunIT Conference 2019Ludmila Nesvitiy
 
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)James Titcumb
 
GraphQL IN Golang
GraphQL IN GolangGraphQL IN Golang
GraphQL IN GolangBo-Yi Wu
 
Top 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesTop 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesCarol McDonald
 
Universal JavaScript
Universal JavaScriptUniversal JavaScript
Universal JavaScript名辰 洪
 
Building @Anywhere (for TXJS)
Building @Anywhere (for TXJS)Building @Anywhere (for TXJS)
Building @Anywhere (for TXJS)danwrong
 
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディングXitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディングscalaconfjp
 
Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014Ngoc Dao
 

Similar a Restful Web Service (20)

Node.js server-side rendering
Node.js server-side renderingNode.js server-side rendering
Node.js server-side rendering
 
Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018
 
AWS re:Invent 2016: Chalice: A Serverless Microframework for Python (DEV308)
AWS re:Invent 2016: Chalice: A Serverless Microframework for Python (DEV308)AWS re:Invent 2016: Chalice: A Serverless Microframework for Python (DEV308)
AWS re:Invent 2016: Chalice: A Serverless Microframework for Python (DEV308)
 
Test-Driven Documentation for your REST(ful) service
Test-Driven Documentation for your REST(ful) serviceTest-Driven Documentation for your REST(ful) service
Test-Driven Documentation for your REST(ful) service
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 
Using the Windows 8 Runtime from C++
Using the Windows 8 Runtime from C++Using the Windows 8 Runtime from C++
Using the Windows 8 Runtime from C++
 
Web2Day 2017 - Concilier DomainDriveDesign et API REST
Web2Day 2017 - Concilier DomainDriveDesign et API RESTWeb2Day 2017 - Concilier DomainDriveDesign et API REST
Web2Day 2017 - Concilier DomainDriveDesign et API REST
 
Rack Middleware
Rack MiddlewareRack Middleware
Rack Middleware
 
JavaOne Brasil 2016: JavaEE e HTML5: da web/desktop ao mobile
JavaOne Brasil 2016: JavaEE e HTML5: da web/desktop ao mobileJavaOne Brasil 2016: JavaEE e HTML5: da web/desktop ao mobile
JavaOne Brasil 2016: JavaEE e HTML5: da web/desktop ao mobile
 
Api
ApiApi
Api
 
Coding Ajax
Coding AjaxCoding Ajax
Coding Ajax
 
Coding Ajax
Coding AjaxCoding Ajax
Coding Ajax
 
The battle of Protractor and Cypress - RunIT Conference 2019
The battle of Protractor and Cypress - RunIT Conference 2019The battle of Protractor and Cypress - RunIT Conference 2019
The battle of Protractor and Cypress - RunIT Conference 2019
 
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
 
GraphQL IN Golang
GraphQL IN GolangGraphQL IN Golang
GraphQL IN Golang
 
Top 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesTop 10 Web Security Vulnerabilities
Top 10 Web Security Vulnerabilities
 
Universal JavaScript
Universal JavaScriptUniversal JavaScript
Universal JavaScript
 
Building @Anywhere (for TXJS)
Building @Anywhere (for TXJS)Building @Anywhere (for TXJS)
Building @Anywhere (for TXJS)
 
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディングXitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
 
Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014
 

Último

Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 

Último (20)

Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 

Restful Web Service

  • 1. Group15 Rest Yuan Gao Ning Ma Bin Cai
  • 2. Overview Introduction Technologies and toolkits Architecture Implementation & Security Deploy & Test Analysis and evaluation
  • 3. Introduction RESTful Web Services is different from SOAP- style services using HTTP GET PUT POST DELETE Unique URI to describe Resource
  • 4. Introduction Client 3 Services: TravelAgent, Flight, Hotel Resources: /flight /hotel /booking /query
  • 5. Technologies and Toolkits AJAX: send request and receive response XML: store and transmit data JAX-RS (JSR 311): Java API for RESTful Web Services
  • 6. Technologies and Toolkits Maven: project management Jersey: JAX-RS Reference Implementation for building RESTful Web services Grizzly: Web application container
  • 8. Implementation define classes: import import javax.xml.bind.annotation.XmlRootElement; javax.xml.bind.annotation.XmlRootElement; @XmlRootElement @XmlRootElement public class Flight { public class Hotel { ! ! private int Id; ! private int flightNo; ! private String Name; ! private String from; ! private int price; ! private String to; ! private String address; ! private int departTime; ! public Hotel() {} ! private int arriveTime; ... ! private int price; ! public Flight() {} ... TravelAgent, FlightResource, HotelResource...etc...
  • 10. Some code... @Path("/flight") @Produces("application/xml") public class FlightResource { ! ! public TreeMap<Integer, Flight> flightMap = new TreeMap<Integer, Flight>(); ... ! @GET ! public List<Flight> getFlights() { ! List<Flight> flights = new ArrayList<Flight>(); ! flights.addAll(getFlightMap().values()); ! return flights; ! }
  • 11. Some code... ... @GET ! @Path("{flightNo}") ! public Flight getFlight(@PathParam("flightNo") int cId) { ! return getFlightMap().get(cId); ! } ...
  • 12. Security HTTPS: use class HTTPSProperties to set javax.net.ssl.HostnameVerifier and javax.net.ssl.SSLContext @Context SecurityContext customer if (customer.isUserInRole("user") {    return new Flight();    } else {    return “please provide effective customer”;    }
  • 13. Deploy <web-app> <servlet> <servlet-name>Jersey Web Application</servlet-name> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>uk.ac.soton.ecs.comp6017</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Jersey Web Application</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> </web-app>
  • 14. Test use Jersey client api to set up test case try { ! ! System.out.println("==> Test 1: Get all flight "); ! ! ! ClientConfig config = new DefaultClientConfig(); ! ! Client client = Client.create(config); ! ! client.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, true); ! ! WebResource service = client.resource("http://localhost:8080/"); System.out.println(service.path("rest2011").path("travelagent").type(MediaType.APPLICATION_FORM_ URLENCODED).get(String.class)); System.out.println("n"); ! } ...
  • 15. Analysis and evaluation Understanding REST architecture Use toolkits to implement scenario Challenges Work as a team

Notas del editor

  1. Good afternoon ladies and gentlemen. We appreciate the opportunity to be with you. This is Cai bin, the leader of our group, this is Ma ning and I am Gao yuan. The topic of our group is REST.\n
  2. Basically, we have divided our presentation into six parts. We will start by an introduction of the project and the technologies and toolkits which should be used in our project. Next, we will discuss its implementation, security, deploy and test. And to finish off, we will analyse and evaluate our project.\n
  3. REST is short for Representational State Transfer, which is a way of design and development for web applications. It is different from soap style services. RESTful web services use HTTP protocol to send and receive messages. In the rest, all the things are abstracted as resources and each resource has a unique URI.\n
  4. Our project consists of one client, three services and some resources. The client of our project is used ajax and the three services are travel agent, flight and hotel. We define different URLs to mark different resources such as flight, hotel, booking and query.\n
  5. Now, let&amp;#x2019;s move on to the next part of our presentation: the technologies and toolkits. We apply three main technologies to realize our project: ajax and xml and jax-rs. Ajax is used to send request and receive reponse and xml is used to store and transmit data. Jax-rs is a java application for restful web services.\n
  6. We also use three toolkits to complete our project: Maven, Jersey and Grizzly. Maven is a project management which is to manage the whole project. Jersey is a jax-rs reference implementation for building restful web services which provides API as an interface. Grizzly is a web application container.\n
  7. This is the architecture diagram of our project. We have already explained it before. So we skip this slide.\n
  8. Hello, everyone. I will step into the implementation part of our presentation now. &amp;#xA0;Because we are going to implement three services which are travelagent, flight and hotel, we define several classes at first. For example, we use flgiht class to define a flight and hotel class to define hotel. &amp;#xA0;As you can see from the code, we use XMLRootElement annotation to declare the data format of XML and we also add some attributes to the entities. Other classes, such as TravelAgent, FlightResource, HotelResource, are set up to execute requested command and return response.\n
  9. We use Jersey as our toolkit. Because it provide JAX-RS implementation APIs which are easy to use. The annotations which can be used as interface. The Path annotation will define a url path where the resource is located. GET and POST annotation will receive HTTP get or post request and execute the code blew. Produces annotation define the &amp;#xA0;returned data format. There are also other annotations that can be used. Now let&amp;#x2019;s look at some pieces of code as example.\n
  10. This is some code in FlightResource class. We use @path(&amp;#x201C;/flight&amp;#x201D;) to define the flight resource as slash flight and @Produces(&quot;application/xml&quot;) to declare the returned data format is XML. We use TreeMap to store the flight information. When the service receive a get request, the code blew @GET will execute and return the all flights.\n
  11. When the service receive a get request with a specific flightNo, this code will execute and return the requested flight information. The PathParam annotation will get the value of flightNo and pass to cId. Other annotations include QueryParam @Context and so on.\n
  12. Security is really a problem in restful web services, as WS-security is not suitable for rest. Fortunately, we can use HTTPS to enhance the basic http authentication. HTTPS can ensure the request form and return message to the right customer. We use class HTTPSProperties to set up these two packages. For authentication, we use @Context annotation to receive user identity and use these code to verify it.\n
  13. what we create is a web application which will be hosted on a server. We use grizzly as the web container. This is the code in web.xml which config the deployment of our application. The red lines define the parameters which will deploy the package to the servlet\n
  14. For test, we used Jersey client API to set up our test cases. You can see from the code, which is a sample of test case. In this test, the client will send a get request to the travelagent which &amp;#xA0;will return options of available flights and hotels.\n
  15. Hi, everyone! I will finish this presentation with the last part, which is the analysis and evaluation of our project. Before we start this coursework, we have little experience of neither web service nor rest style. So we spend some time to understand the conception of rest architecture. This is a fundamental process of studying by ourselves. Until now I think we have already had a good understanding of restful web services. After we started, we compared some toolkits such as CXF, Axis2 and so on, while we chose jersey as the source community finally. Because Jersey provides complete Java APIs for restful web services which are easy to use and implement.\n\nWe also came across some challenges. When we were going to implement security in our project, we found it is difficult to use WS-security in restful web service and other methods maybe not suitable for our scenario and Jersey is lack of the security APIs to use. So we use transport layer security which is HTTPs instead of application layer security. For test, we cannot write regular unit test case and we had to choose using jersey client to test our project.\n\nThe last point is that we always work as a team. We discuss and think about the way to implement our project together and share the gains with others. As a member of this group, I developed the travel agent service, Bin developed flight service and Test function, and Yuan implement hotel service and security. We did really hard work to complete our work. So I hope everyone can enjoy our project and this presentation.\nThank you!\nAny question?\n
  16. Thank you!\nAny questions?\n