Webservices
By using webservices we can communicate different applications on different platforms. For example java application in Windows platform can easily communicate with the application developed using .net/php in Linux operation system.
Web Services are mainly of 2 types,
-
SOAP [Simple Object Access Protocol]
-
REST [Representational state transfer]
1. SOAP [Simple Object Access Protocol]
SOAP stands for Simple Object Access Protocol. SOAP is an XML based industry standard protocol for designing and developing web services. Since it’s XML based, its platform and language independent. So our Service can be based on JAVA and client can be on .NET, PHP etc. and vice versa. SOAP gives the output only in XML format
We have following API’s to implement SOAP Webservices in our java applications
-
JAX-WS
-
Apache Axis2
-
URI - Uniform Resource Identitier
-
URL - Uniform Resource Link
2. REST [Representational state transfer]
-
What ever the data/response we will get from the server is known as Resource.
-
Each resource can be accessed by its URI’s.
-
We can get the resource from RESTful service in different formats like, HTML, XML, JSON, TEXT, PDF and in the Image formats as well, but in real time we mainly we will prefer JSON.
-
REST guidelines always talks about stateless communication between client and the Server. Stateless means, every single request from client to server will be considered as a fresh request. Because of this reason REST always prefers to choose HTTP as it a stateless protocol
We have following API’s to implement RESTful Webservices in our java applications
- JAX-RS
Apache CXF provides implementation for SOAP and RESTful services both.
REST is a style of software architecture. RESTful is typically used to refer to web services implementing such an architecture
No. | SOAP | REST |
---|---|---|
1) | SOAP is a protocol. | REST is an architectural style. |
2) | SOAP stands for Simple Object Access Protocol. | REST stands for REpresentational State Transfer. |
3) | SOAP can’t use REST because it is a protocol. | REST can use SOAP web services because it is a concept and can use any protocol like HTTP, SOAP. |
4) | SOAP uses services interfaces to expose the business logic. | REST uses URI to expose business logic. |
5) | JAX-WS is the java API for SOAP web services. | JAX-RS is the java API for RESTful web services. |
6) | SOAP **defines standards **to be strictly followed. | REST does not define too much standards like SOAP. |
7) | SOAP requires more bandwidth and resource than REST. | REST requires less bandwidth and resource than SOAP. |
8) | SOAP defines its own security. | RESTful web services inherits security measures from the underlying transport. |
9) | SOAP permits XML data format only. | REST permits different data format such as Plain text, HTML, XML, JSON etc. |
10) | SOAP is less preferred than REST. | REST more preferred than SOAP. |