0
2.4kviews
written 5.8 years ago by |
1 HTTP methods
Following four HTTP methods are commonly used in REST based architecture.
GET − Provides a read only access to a resource.
POST − Used to create a new resource.
DELETE − Used to remove a resource.
PUT − Used to update a existing resource or create a new resource.
2 RESTFul web services
Sr.No. | URI | HTTP Method | POST body | Result |
---|---|---|---|---|
1 | /UserService/users | GET | empty | Show list of all the users. |
2 | /UserService/addUser | POST | JSON String | Add details of new user. |
3 | /UserService/getUser/:id | GET | empty | Show details of a user. |
3.12 Comparison of SOAP AND REST
SOAP | REST |
---|---|
SOAP stands for Simple Object Access Protocol | REST stands for Representational State Transfer |
SOAP is a protocol. SOAP was designed with a specification. It includes a WSDL file which has the required information on what the web service does in addition to the location of the web service. | REST is an Architectural style in which a web service can only be treated as a RESTful service if it follows the constraints of being Client Server Stateless Cacheable Layered System Uniform Interface |
SOAP cannot make use of REST since SOAP is a protocol and REST is an architectural pattern. | REST can make use of SOAP as the underlying protocol for web services, because in the end it is just an architectural pattern. |
SOAP uses service interfaces to expose its functionality to client applications. In SOAP, the WSDL file provides the client with the necessary information which can be used to understand what services the web service can offer. | REST use Uniform Service locators to access to the components on the hardware device. For example, if there is an object which represents the data of an employee hosted on a URL as https://demo.guru99 , the below are some of URI that can exist to access them https://demo.guru99.com/Employee https://demo.guru99.com/Employee/1 |
SOAP can only work with XML format. As seen from SOAP messages, all data passed is in XML format. | REST permits different data format such as Plain text, HTML, XML, JSON, etc. But the most preferred format for transferring data is JSON. |