			 	               "Welcome To Ashok IT"				
			                       "Spring Boot & Microservices"
                                             Topic  : Introduction To Restful Webservices
                                              Date  : 17/12/2024
                                                  (Session-87)                          
_____________________________________________________________________________________________________________________________
Restful Webservices
===================
* Rest stands for "Representational State Transfer".

* Rest is not protocal it is an architectural style of developing the Webservices and the author of Http protocal 
 "Roy Fielding" provided some certain rules and guidelines for Restful webservices.

* In Restful Webservices as well request and response of Producer & consumer Application will transfer through Http protocal.

* Restful WebServices allows to send data in both global formats such as "XML & JSON" and it always recommended for sending     data as "JSON" Format.

* Converting Java Object into XML Content    >>>>>>>>>>>>>>> Marshalling

  Converting XML Content into Java Object    >>>>>>>>>>>>>>> Unmarshalling

  Marhsalling & Un-Marshalling can be performed with help of "JAX-B API".

  Converting Java Object into JSON           >>>>>>>>>>>>>>> Serialization

  Converting JSON into Java Object           >>>>>>>>>>>>>>> De-Serialization

  Serialization & De-Serialization can be performed with help of "JACKSON API" (or) "GSON API".

* Inorder to develop the Restful webservices we have below options

   1) JAX-RS Specifications provided by Sun microsystem and having some implementations "Jersey(Formely(GlassFish) and              currently moved to Eclipse Foundation)" & "Rest Easy(JBOSS/RedHat)".(Traditional approach)

   2) By Using Spring Rest Module For Developing the Restful Webservices.(Modern Approach)

* In this kind of Webservices the provider application will expose their services using WADL(Web Application Description        Language) Documentation or Swagger Documentation to get more information related Rest Services.

      REST    >>>>>>>>>>> It is standard for developing RestAPI's
    
      RestFul >>>>>>>>>>> Creating API based on Rest.

* Following are the below Rest Design Principles

   1) Everything is to be Resource in Rest API's
 
       Ex: EmployeeResource,LoginResource,RegistrationResource,CustomerResource etc.,

   2) Each Resource in the Rest API's are identified by Unique URI.

   3) Use the Standard Http Request Methods i.e.,Get,Post,Put,Patch,Delete.

         GET      >>>>>> Getting the data from server                 >>>>> @GetMapping

         POST     >>>>>> Sending data to server                       >>>>> @PostMapping

         PUT      >>>>>> Updating data to server for completely       >>>>> @PutMapping

           Example : Customer contains 5 properties we are trying to update only for 2 fields We need to pass the 5 fields to                      update the resources.

         PATCH    >>>>>> Updating data to server for Partially        >>>>> @PatchMapping

           Example : Customer contains 5 properties we are trying to update only for 2 fields We need to pass the 2 fields to                      update the resources.

         DELETE   >>>>>> Deleting data from server                    >>>>> @DeleteMapping

         @RequestMapping(value="url pattern", method=RequestMethod.GET/POST/PUT/PATCH/DELETE)  >>>>> up to spring 4.x

   4) Allow Multiple Representations for same Resource

   5) Communication should be always Stateless.
        
         |-> By default Http protocal is stateless protocal means that every request in webapplication (or) rest apis should               be independent.

         |-> Http Protocal doesn't remember the previous requests related information.

         |-> If we want Http Protocal becomes as Stateful we need to apply "Session Tracking" mechanism.    


Differences between SOAP Vs Rest
================================
Soap Webservices
================
1) It is traditional approach for developing Webservices.

2) To develop this kind of webservice required JAX-WS Library.

3) The Implementation for this library are  Apache Axis,Apache CXF etc.,

4) SOAP Messages are transferred over Http Protocal

5) Service Registry is required for storing webservices related information

6) Services Information will be provided through WSDL Documentation.

Restful Webservices
===================
1) It is modern approach for developing webservices.

2) To develop this kind of webservice required JAX-RS Library/Spring Rest/SpringBoot Rest.

3) The Implementation for this library are SpringRest,RestEasy,Jersery etc.

4) JSON Data will transfer over Http Protocal.

5) Here no Registry is required.

6) Services Information will be provided through WADL/Swagger Documentation.