Representational State Transfer (REST)
In web services there are 2 architectural styles:
1) soap style
2) rest style
Key difference in choosing REST and SOAP :
If our project requirement is to represent same data but in diff formats such as xml, json, html, etc then go for REST style.
In REST style, message layer security is not possible rather only transport layer security using https is possible.
In SOAP style, we can provide security both at message layer security as well as transport layer.
Hence if our project requirement is more robustness then go for SOAP style.
--------------------------------------------------------------------------
SOAP
The following APIs are used to develop SOAP based applications:
1) AXIS2 API
2) JAX-RPC API
3) JAX-WS API
4) Apache CXF Framework [Preferred]
Kind of key Responsibilities for beginners implementing SOAP in the project :
1) Developed services using Apache CXF framework.
2) Configured services as beans in spring configuration file using DI.
3) Tested services using SOAP UI.
REST
The following APIs are used to develop REST based applications:
1) JAX-RS API - Jax-rs runtime env does following:
- Receives HTTP request message
- Extract xml message from above http req message
- Delegates to jaxb and passes above xml message
- Wait for object from jaxb
- Invokes resource method & passes above object as an argument.
- If required, Response object internally created.
- The above Response object is converted to HTTP response message & sends back to client application.
1) JAX-RS Specification
-SUN
-.pdf [JSR-311]
-Description
2) JAX-RS API
-SUN
-Mostly annotation names, mostly interface names and few classes
-javax.ws.rs package
-javax.ws.rs.core package
-javax.ws.rs.ext package
3) JAX-RS Implementation
-Third party vendors such as Apache, Sun, JBoss, etc
-Impl classes for all interfaces and annotation names in JAX-RS API
-APACHE CXF [from APACHE]
-JERSEY [from SUN]
-RESTEasy [from JBOS]
2) SPRING with REST API [Preferred]
3) JAX-WS API
4) Apache CXF Framework
Kind of key Responsibilities for beginners implementing REST in the project :
1) Developed resources using SPRING with REST.
2) Configured resources as beans in spring configuration file using DI.
3) Tested resources using SOAP UI/ POSTMAN plug-in.
4) Consumed resources using RestTemplate.
- REST vs SOAP.
- HTTP Protocol.
- HTTP Methods.
- HTTP Status Codes.
- Architectural Principles
https://www.baeldung.com/rest-with-spring-series
https://www.baeldung.com/spring-interview-questions#Q4
Diff between soap style & rest style
===========================
soap style
----------
1) The data is represented in soap format.
2) Uses diff transport protocols such as http, https, jms, ftp, smtp, tcp, etc.
3) Uses http just as transport protocol.
4) Exceptions are handled using soap fault codes.
5) The service (means business component) is described using WSDL (Web Services Description Language)
6) It is action oriented hence class names and method names are important.
rest style
----------
1) The data is represented in plain xml format i.e., the soap protocol is not required.
2) Always uses only http/https as transport protocols.
3) Uses http protocol completely (uses http protocol as more than trapsport protocol) such as http methods, http status codes, etc are used.
4) Exceptions are handled using http error status codes such as 4xx, 5xx.
5) The resource (means business component) is described using WADL(Web Application Description Language)
6) It is representation oriented where representation means formats such as xml, json, yaml, html depending on client preference.
Note: The rest style never uses XSD, SOAP, WSDL and UDDI.
Filters and Interpretors.
No comments:
Post a Comment