Understanding REST architecture and implementation in modern web applications
REST (REpresentational State Transfer) is an architecture principle where web services are viewed as resources uniquely identified by URLs. The key characteristic of RESTful Web services is the explicit use of HTTP methods to denote different operations.
Create a resource
Retrieve a resource
Update a resource
Delete a resource
Let's explore a practical example using Arduino with GPS tracking capabilities. This example demonstrates how to implement REST services in an IoT context.
http://www.test.org/Georeference.aspx?SOURCE=74KM&TIME=00:11:36&DATE=04/01/01&LATITUDE=1233.715480&LONGITUDE=4155.726918
Here's a sample implementation of the georeference handler:
//GeoReferences.aspx
//Author: Vittorio Margherita
//Version 4.51
public partial class WebForm1 : System.Web.UI.Page
{
string ArduSource;
string ArduTime;
string ArduDate;
string ArduLatitude;
string ArduLongitude;
bool QueryMissedParam;
protected void Page_Load(object sender, EventArgs e)
{
XmlTextWriter writer = new XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8);
DateTime TimeOfTheDay, DayOfTheDate;
GeoReference GeoString = new GeoReference();
DatabaseConnectionDataContext db = new DatabaseConnectionDataContext();
ArduSource = Request.QueryString["SOURCE"];
ArduTime = Request.QueryString["TIME"];
ArduDate = Request.QueryString["DATE"];
ArduLatitude = Request.QueryString["LATITUDE"];
ArduLongitude = Request.QueryString["LONGITUDE"];
//check if the current App is authorised to work
var query =
from righe in db.AllowedPCCs
where
(righe.PCC == ArduSource)
select righe;