0% found this document useful (0 votes)
55 views13 pages

t01 Rest Hello World

This document provides instructions for setting up a RESTful web services tutorial using IntelliJ IDEA, Maven, and JAX-RS. It discusses installing the necessary software, generating a JAX-RS project template with Maven, implementing base classes and a REST API class, and using cURL to test the API by performing CRUD operations.

Uploaded by

Brent Liang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views13 pages

t01 Rest Hello World

This document provides instructions for setting up a RESTful web services tutorial using IntelliJ IDEA, Maven, and JAX-RS. It discusses installing the necessary software, generating a JAX-RS project template with Maven, implementing base classes and a REST API class, and using cURL to test the API by performing CRUD operations.

Uploaded by

Brent Liang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Tutorial 1 - RESTful

Web Services

SOEN 487 - Web Services and Applications


By: Nicholas Nagy
IntelliJ IDEA by Jetbrains
- IntelliJ IDEA is a multi-platform IDE that focuses on Java Development
- It is made by the same company that developed Kotlin (the official language for
Android development)
- Jetbrains also makes a lot of IDEs for other popular programming languages with
many of the same shortcuts.

Installation Instructions

1. Get access to your concordia email/outlook if you haven’t already (see link)
2. Watch the IDE Overview
3. Download the ultimate version at https://www.jetbrains.com/idea/download/ and use
your concordia email to gain access

Winter 2021
Maven and JDK 8 or higher

Apache Maven is a software project management and comprehension tool that is based on the
concept of a project object model (POM).

We will be using Maven to generate a Jersey template (a JAX-RS implementation) for us to work
with.

Install links for Maven: Download, Install, Run

Install link for JDK: Zip file

Winter 2021
Postman and Curl

Postmanis a collaboration platform for API development, and Curl is a command line tool for
doing all sorts of URL manipulations and transfers.

We will be using them to test and consume our REST API.

The download link for postman can be found here.

And the download link for curl can be found here.

Winter 2021
What about the Application Server?

We will be using the Grizzly HTTP server module in this tutorial, so we won’t actually need to
install an external Application Server.

You can still use Tomcat, Glassfish, Jetty or any other application server if you wish, as long as
you’re using JAX-RS to handle requests.

Winter 2021
What is a REST API?

- REST is an acronym for


REpresentational State Transfer.
- It helps abstract the client away from
the server and provides a means for
them to communicate.
- All communications are stateless, so
they need to contain all the required
information to understand the
request within them.
- More Restful API Notes

Winter 2021
CRUD Operations

Operation HTTP Method

Create POST

Retrieve GET

Update PUT (Replace), PATCH (Modify) Source

Delete DELETE

Winter 2021
Generating a JAX-RS Project

Generation Command:
mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-grizzly2 -
DarchetypeGroupId=org.glassfish.jersey.archetypes -
DinteractiveMode=false -DgroupId=com.example.rest -DartifactId=jersey-
service -Dpackage=com.example.rest -DarchetypeVersion=2.17

Generating Jersey Project using Maven

Or download the template on my Github Repository.

Winter 2021
Base Classes

Winter 2021
Rest API Class - Part 1

Winter 2021
Rest API Class - Part 2

Winter 2021
Using cURL to test our API
# Creates users

curl -X POST http://localhost:8080/restaurant/customer/nick/24

curl -X POST http://localhost:8080/restaurant/customer/ali/30

curl -X POST http://localhost:8080/restaurant/customer/Kosta/30

curl -X POST http://localhost:8080/restaurant/customer/Hamed/24

# Modifies a user

curl -X PUT http://localhost:8080/restaurant/customer/0/nick2/26

# Deletes a user

curl -X DELETE http://localhost:8080/restaurant/customer/1

# Gets the list of users

curl http://localhost:8080/restaurant/customer
Winter 2021
References

- IntelliJ Logo
- Patch Method Specs
- More Information on the Maven POM
- Restful API Info
- Restful API Image
- Generating Jersey Project using Maven
- Tomcat Logo
- Glassfish logo

Winter 2021

You might also like