Distributed Systems
Lecture -6-
Created by :
Eng. Ghadeer Al Hasan
Restful Web Services
Intro 1
• REST is the acronymfor REpresentational State Transfer.
• REST is an architectural style for developing applications that can be accessed over the network.
• Restful Web Services is a statelessclient-server architecture where web services are resources and can
be identified by their URIs.
• REST Client applications can use HTTP GET/POSTmethods to invoke Restful web services.
• REST doesn’t specify any specificprotocol to use, but in almost all casesit’s used over HTTP/HTTPS.
• We can use XML, JSON, text or any other type of data for request and response.
Java RESTful Web Services API 2
• Java API for RESTful Web Services (JAX-RS) is the Java API for creating RESTweb services.
• JAX-RS uses annotations to simplifythe development and deployment of web services.
• JAX-RSis part of JDK, so you don’t needto include anything to use it’s annotations
Restful Web Services Annotations 3
Some of the importantJAX-RS annotations are:
• @Path: used to specify the relative path of classand methods. We can get the URI of a webservice
by scanning the Pathannotationvalue.
• @GET , @PUT , @POST , @DELETEand @HEAD: usedto specify the HTTPrequest type for a
method.
• @Produces , @Consumes : usedto specify therequest and responsetypes.
• @PathParam: used to bindthe method parameter to pathvalue by parsing it.
UserWS Example
Requirement 5
- Install “Wamp Server” on your machine
- Create Database “RestWS”
- Create Tables…
Create Tables 6
create table Accounts (
accountId bigint not null primary key AUTO_INCREMENT,
username varchar(100) not null,
password varchar(100) not null);
)
create table Users(
userId bigint not null primary key AUTO_INCREMENT,
firstName varchar(200) not null,
lastName varchar(200) not null,
BirthDate varchar(30) not null,
gender bit not null, accountId bigint not null,
foreign key (accountId) references Accounts(accountId)
);
AccountsFacadeREST Class 7
AccountsFacadeREST Class 8
UsersFacadeREST Class 9
UsersFacadeREST Class… 10
Test Services 11
Test Services 12
References 13
- YouTube link
https://www.youtube.com/playlist?list=PLtDIUAtyP4lhV7CsYfLuIx26UeG4J-ujZ
- GitHub
https://github.com/Ghadeerof
End Lecture

#6 (RESTtful Web Wervices)

  • 1.
    Distributed Systems Lecture -6- Createdby : Eng. Ghadeer Al Hasan Restful Web Services
  • 2.
    Intro 1 • RESTis the acronymfor REpresentational State Transfer. • REST is an architectural style for developing applications that can be accessed over the network. • Restful Web Services is a statelessclient-server architecture where web services are resources and can be identified by their URIs. • REST Client applications can use HTTP GET/POSTmethods to invoke Restful web services. • REST doesn’t specify any specificprotocol to use, but in almost all casesit’s used over HTTP/HTTPS. • We can use XML, JSON, text or any other type of data for request and response.
  • 3.
    Java RESTful WebServices API 2 • Java API for RESTful Web Services (JAX-RS) is the Java API for creating RESTweb services. • JAX-RS uses annotations to simplifythe development and deployment of web services. • JAX-RSis part of JDK, so you don’t needto include anything to use it’s annotations
  • 4.
    Restful Web ServicesAnnotations 3 Some of the importantJAX-RS annotations are: • @Path: used to specify the relative path of classand methods. We can get the URI of a webservice by scanning the Pathannotationvalue. • @GET , @PUT , @POST , @DELETEand @HEAD: usedto specify the HTTPrequest type for a method. • @Produces , @Consumes : usedto specify therequest and responsetypes. • @PathParam: used to bindthe method parameter to pathvalue by parsing it.
  • 5.
  • 6.
    Requirement 5 - Install“Wamp Server” on your machine - Create Database “RestWS” - Create Tables…
  • 7.
    Create Tables 6 createtable Accounts ( accountId bigint not null primary key AUTO_INCREMENT, username varchar(100) not null, password varchar(100) not null); ) create table Users( userId bigint not null primary key AUTO_INCREMENT, firstName varchar(200) not null, lastName varchar(200) not null, BirthDate varchar(30) not null, gender bit not null, accountId bigint not null, foreign key (accountId) references Accounts(accountId) );
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
    References 13 - YouTubelink https://www.youtube.com/playlist?list=PLtDIUAtyP4lhV7CsYfLuIx26UeG4J-ujZ - GitHub https://github.com/Ghadeerof
  • 15.