5 Main Things You Need to Know about Web Services

by Techflier 709 views0

In this day and age, open is the formula to longevitywhether it be open architecture, open standards, or open source. The successes of Facebook, Twitter, and Google Apps have been in large part due to their respective platform’s open operability through APIs, allowing developers to build 3rd party applications on top of their offerings. And by and large, the most popular way to implement open operability is through web services. The following are 5 main things you need to know about web services to have an intelligent conversation about the web.

1. A web service is a common way for two or more programs to communicate.

Source: Butupa / Flickr Creative Commons.

More specifically, it consists of an API that enables two applications to interchange data through a common format. For example, Facebook’s API allows developers to build applications that can authenticate against the popular social network’s user database. Twitter’s API allows developers to build functionality that enable users to tweet directly from their application, whether it be a custom mobile app, web site, etc.

2. The most popular way to implement a web service these days is with REST.

Source: Donald Hines / Flickr Creative Commons.

No, we’re not talking about catching some Zs. There are many ways to implement web services in an application. Representational State Transfer (REST) is a popular approach because it is built heavily around HTTP. And since HTTP is the standard protocol of the web, web developers tend to embrace REST as the web service design pattern of choice. REST can be used with widely-adopted data formats such as JSON and XML, though the former has become more popular in recent years. REST stands for Representational State Transfer. REST stresses utilizing the native architecture of the web in your application, and is hence a lightweight and extensible design pattern. When applications are built around REST, they are said to be “RESTful”.

3. REST is based on HTTPthe underlying protocol of the web.

Source: Yuri Samoilov / Flickr Creative Commons.

RESTful applications use HTTP requests to carry out CRUD, or “create/read/update/delete” operations. This is accomplished through using native HTTP operations PUT, GET, POST, and DELETE, with emphasis on GET and POST as the most commonly used methods.

4. When it comes to web services, URL says it all.

Source: Joe deSousa / Flickr Creative Commons.

A REST application is made up of interactive elements, or “resources” that can be manipulated to retrieve data or carry out actions. Each resource is identified by an ID, and is accessed through a URI.

Take a look at the following:

http://www.mycompanywebsite.com/companydirectory/EmployeeName/1234

This fictional REST web service queries a company directory web application for the name of the employee whose user ID is 1234. It accomplishes this through a simple HTTP GET method, and its HTTP reply is the data of the result set– namely, the details of employee 1234, in a data format that can be readily used and manipulated.

5. JSON is the predominant data format used in web services today.

Source: Noah Sussman / Flickr Creative Commons.

JSON is the most popular data format used these days with REST. It stands for “JavaScript Object Notation,” as it was originally derived from the JavaScript language. We’ll not delve too much into JSON’s merits, as this is a lengthy topic unto itself. Just keep in mind that PHP embraces JSON and has a whole set of function specifically for encoding and decoding JSON responses/objects, making this data format ideal for PHP/LAMP applications. In the previous example, we queried the web service for the details of employee 1234. The JSON response might look something like this:

{"firstName": "John", "lastName": "Doe"}

As you can see, the data is human-readable and easy to parse. This employee’s first name is “John,” and his last name is “Doe.”

In short, web services are the key to making a website’s data and functionality widely accessible and sharablethe glue that holds the web’s data together.  And again, most web services use REST and adhere to RESTful principles.

 

Source(s):

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>