Practice Project implementing REST api in Server Side Project & Consume it with Client side Project
Older version of project : https://github.com/Abdelhakim-gh/JakartaEE-Project
Firstly, I have to inform you that I'm not using POST and PUT requests in my API because I had a problem where the body of the request is not working. So instead, I'm using GET and DELETE, and for POST and PUT, I'm using GET with parameters and endpoints that are clear to understand like:
-
Resource\add: represents the creation of an element.
-
Resource\edit: represents modifying an element.
-
Here is the structure of my API URL:
<HTTP_Method> <Address>:<Port>/<Project_Name>/<Resource>/<[Operation]?[Parameters]> Example: Client Side: GET http://localhost:8083/Jee_projet/RestReadEtudiant Server Side: GET http://localhost:8083/SOA_Project/Etudiants
- Where operations are: [add - edit - remove].
- And for retrieve, I use:
<Resources>
to retrieve all and<Resources>/id
to retrieve one element.
-
For adding resources: Use a GET request with appropriate parameters to the
/Resource/add
endpoint. -
For editing resources: Use a GET request with appropriate parameters to the
/Resource/edit
endpoint. -
For removing resources: Use a DELETE request to the
/Resource/remove
endpoint. -
For retrieving resources: Use a GET request to the
/Resources
endpoint for retrieving all resources, and/Resources/{id}
endpoint for retrieving a specific resource by ID.
- I’ve tried changing the libs version.
- Activating content-type & accept with
Json
,xml
support & it didn't work.
# admin
abdo@gmail.com
abdo
# prof
pariwo@mailinator.com
Pa$$w0rd!
# etudiant
tiriximi@mailinator.com
Pa$$w0rd!
- Import the SQL DB in MySQL
jeegestionprojet.sql
. - Run the
SOA_Project
on port8083
or change the consuming port in the Client ProjectJee_Project
. - Run the second project.
- Import SOA
Project.postman_collection.json
&Jax RS API Consumer JEE.postman_collection.json
to Postman. - Start testing requests with Postman or execute directly in the browser since I don't have a request body.
Strucuture by feature
- User - Etudiant - Prof ….
**UserDAO**
→ talk to DB for user table**EtudiantDAO
** → talk to DB for etudiant table- …
**UserService**
→ logic of feature (create - read - update - delete)**EtudiantService**
- …
**FeaturesController**
→ handle access to Resource [GET - POST -PUT - DELETE]- User
- Etudiant
- …
MVC Structure