HTTP Web Services requests GET, POST, PUT, DELETE Flashcards
Service Class
Encapsulates the functionality of code that works as a unit or provides a specific business purpose.
Types of HTTP Methods
- Safe - GET (Not Safe - POST, PUT, DELETE).
2. Idempotent - GET, PUT, DELETE (Not Idempotent - POST).
Safe HTTP Method
A request that does not change the server.
Idempotent HTTP Method
A request that has the same result regardless of how many times it is completed.
HTTP Methods - GET Usage
Generally used to retrieve web pages to display (images, documents, stylesheets, script files, search pages).
GET Method Characteristics
GET requests are easily bookmarked because the parameters are in the URL. GET does not change the state on the server and has the same result each time it is repeated so it is Safe Idempotent.
Serialization
Transforming a Java Object to a string representation of the object, JSON. Object → JSON
Deserialization
Transforming a string representation of an object, JSON, into a Java Object. JSON → Object
HTTP Methods - POST Usage
Used when:
- Data must be secure (credit card number, password, etc.)
- Data is too large for the URL.
- When the request is asking to add something on the server.
HTTP Methods - POST Usage
- HTTP POST requests cannot be bookmarked or sent with the browser directly.
- Post modifies the server and leaves the server in a different state each time the same request is repeated, so it is Not Safe Not Idempotent.
- POST transfers data in the message body instead of the URL.
- While HTTPS encrypts the message body, it cannot encrypt the URL.
HTTP Methods - PUT Usage
Used to:
- Update existing data.
- Meant to overwrite the entire record with the new values.
HTTP Methods - PUT Characteristics
- Cannot be bookmarked or sent with the browser directly.
- Indicates that the request will update existing data on the server.
- Put changes the state on the server but the state remains the same if the same request is repeated multiple times, so it is Not Safe Idempotent
HTTP Methods - DELETE Usage
Used to:
- Remove existing data from the server.
- Only requires the entity’s id, so parameters are sent in the query string.
HTTP Methods - DELETE Characteristics
- Cannot be bookmarked or sent with the browser directly.
- This indicates that the request will remove existing data from the server.
- Delete changes the state of the server but the state remains the same if the request is repeated multiple times, so it is Not Safe Idempotent.