Join David Gassner for an in-depth discussion in this video Associating REST actions with HTTP request methods, part of Foundations of Programming: Web Services.
- View Offline
The REST architecture was originally described in conjunction with HTTP and is usually implemented with it but like so, it can also be implemented with other protocols. But, when used with HTTP it uses the same established request response patterns that are used by web browsers. When a user of a web browser enters a URL and presses enter, or clicks go. That creates an http get request. And when the user fills in a data entry form, and clicks the submit button.
That can create either a get or a post request depending on how the form is constructed. In a browser environment, the server returns either a static HTML page or one that's constructed dynamically by an application server, driven by PHP, ASP.net or Java EE. It may also return binary files such as images, just like a dynamically constructed HTML page. A REST based service returns content that's generated dynamically based on the nature of the request.
RESTful services aren't limited to listening for Get and Post requests. In fact, a fully implemented RESTful service will interpret HTTP request methods as requests for particular actions on the server. And then of course the data is returned as XML or JSON. The most common http methods that are supported in web services are get, post, put, and delete, and some services also support patch or merge. In the web service that allows changes to the server side data, each HTTP request method has a specific meaning.
A GET request can mean give me some data. A head request can mean return metadata such as a headline or a subject line but don't send back the entire body. A post request typically means add this to the server side database. While a put or a patch request can mean update this data. And a delete request typically means exactly what it says. Delete this from server side date storage. REST was originally described in conjunction with HTTP.
And is usually implemented with it. But, like Soap, it can also be implemented with other protocols, but when used with HTTP, it uses the same established request response patterns that are used by web browsers. Not all servers, or all web services, support all HTTP methods, and in fact, it's very common for a service to always return the same data. Regardless of the http method. And not all web service clients support all http methods.
For example Adobe's flash player can send get and post requests from within a web page. But transforms less common http methods such as put and delete into post requests. But complex services can sometimes depend on these methods to figure out what they're supposed to do.
- What is a web service?
- Understanding the available transfer protocols and message formats
- Examining SOAP request and response formats
- Creating a simple SOAP service in ASP.NET
- Choosing a SOAP implementation
- Associating REST actions with HTTP requests
- Sending RESTful requests
- Creating OData request URIs
- Securing web services