Saturday, 20 November 2010

DITA Session 06 - Introduction to Web Services and Application Program Interfaces (APIs)

Software has traditionally been a product - marketed, packaged and sold off the shelf, in the same fashion as most durables, with an array of features to serve the needs of the casual home user through to the multinational company. Competing software houses would aim to pack in as many features as possible to provide the most comprehensive product to its target audience, in an attempt to maximise profit. Typical consumers of software products range from the casual home user, small businesses through to multinational companies (and anything else in-between). Software developers have traditionally designed software to be installed and run locally from a computer or server based in-house, with the view that they must cater for all needs, which for the majority of users means paying for many features which will never be used. A far more efficient and cost-effective model would be to only pay for and consume the services we required from software without the extras we will never use. Moreover we could envisaged a case of a user wanting to consume multiple services, thus creating their own unique bespoke service, i.e. the sum of many parts tailored to a certain need.   

Integration between software products is a feature of many off the shelf products, such as Bentley's Microstation, a CAD package is fully integrated with, Bentley Projectwise, an EDRMS specifically for managing .dgn drawing files produced by Microstation. Bentley Projectwise allows metadata about engineering drawings in the database to populate drawing tags, such as title, version, scale, designer etc. and appear in the drawing title block. The ability to exchange data between the two programs in this manner is nothing new or particularly complicated. However this principle has been exploited to much great extent with data stored on the web being shared using software built on Web 2.0 architectures. Network availability and increased bandwidth now allows Web 2.0 architecture to redefine what is possible in terms of sharing data using 'web services'.

Web services are created and offered over the internet to anyone who wishes to consume the service in the form of machine readable data. As the software service reside on a web server, someone wishing to use that service needs to connect to the internet and send a request. The idea of web services, being consumed in this way has been coined 'Cloud Computing'. Or as Governer et al (2009) define it  "Cloud Computing refers to treating computing resources as virtualised, metered services, similar from a consumer's perspective to how we consume other utilities (such as water, gas, electricity, and pay per view cable)" (Governor et al 2009 p. 127)

A definition from WhatIS.com:
Cloud computing is a general term for anything that involves delivering hosted services over the Internet. These services are broadly divided into three categories: Infrastructure-as-a-Service (IaaS), Platform-as-a-Service (PaaS) and Software-as-a-Service (SaaS). The name cloud computing was inspired by the cloud symbol that's often used to represent the Internet in flowcharts and diagrams.
A cloud service has three distinct characteristics that differentiate it from traditional hosting. It is sold on demand, typically by the minute or the hour; it is elastic -- a user can have as much or as little of a service as they want at any given time; and the service is fully managed by the provider (the consumer needs nothing but a personal computer and Internet access). Significant innovations in virtualization and distributed computing, as well as improved access to high-speed Internet and a weak economy, have accelerated interest in cloud computing.
http://searchcloudcomputing.techtarget.com/sDefinition/0,,sid201_gci1287881,00.html

One type of cloud computing phenomenom that has emerged over the last 5 years, Software as a Service (Saas) delivers computational functionality to users without them having to persist the entire application or system on their computers.  (Governor et al 2009)

Web Services are a type of API. An application program interface (API - and sometimes spelled application programming interface) is the specific method prescribed by a computer operating system or by an application program by which a programmer writing an application program can make requests of the operating system or another application.

http://searchexchange.techtarget.com/definition/application-program-interfac Accessed 20-11-2010

Examples of APIs (or web services)

http://www.tutorialspoint.com/webservices/what_are_web_services.htm gives a good overview of web services and a good technical explanation of the components and workings of web services.


Web Services have Two Types of Uses:

1. Reusable application-components.
  • There are things applications need very often. So why make these over and over again?
  • Web services can offer application-components like: currency conversion, weather reports, or even language translation as services.

2. Connect existing software. (APIs for example)

  • Web services can help to solve the interoperability problem by giving different applications a way to link their data.
  • With Web services you can exchange data between different applications and different platforms.
http://www.w3schools.com/webservices/ws_why.asp Accessed 20-11-2010

 Google offers many API's for developers to use here: http://code.google.com/more/
 For example an API written by google allows a static map map to aded to a web page, with markers placed to display locations in the real world. The API is available at the following URL, which when copied into the HTML of a web page allows the map to be displayed.Parameters such as 'cener=Brooklyn Bridge can be amended to any location, markers can be placed by adding in the correct Easting and Northing etc.

http://maps.google.com/maps/api/staticmap?center=Brooklyn+Bridge,
New+York,NY&zoom=14&size=512x512&maptype=roadmap
&markers=color:blue|label:S|40.702147,-74.015794
&markers=color:green|label:G|40.711614,-74.012318
&markers=color:red|color:red|label:C|40.718217,-73.998284&sensor=false

http://code.google.com/apis/maps/documentation/staticmaps/ Accessed 20-11-2010

The advantages to using API's are that I can ad a map to a web page, or several webpages to show locations of objects in the real world, without needing to know how the actual map is coded, which is in reality probably very complex. The API is the interface provided by google, so all I need to do is call the URL as above ensuring the correct parameters are specified for displaying the map and markers.

An example of using the API is shown on my City University web page here.

Mashups

The example web page linked to above, is an example of a very simple mashup, including a Google static map, a Facebook 'like' button and a Twitter feed, all made available through the respective API. In effect we have mashed together three APIs to create our web page, with ease. I reality this is only the tip of the iceberg, with experience developers using Javascript to call on web services, manipulate the information provided and display it for our own purposes.

For example, a website may contain a directory listing businesses throughout a city stored as structured data in a database, and allow a user to search using keyword for a business, e.g. furniture retailers, within 20 miles of a specified location, and display the results in a Google map. The Javascript code would call the Google maps API, but making the necessary changes to add the markers relevant to the search results. The owner of the website may also wish to included adverts in a side bar of the website, and could then use the Google AdSense API, and target adverts depending on what the user searches for, for example advertise furniture retailers

JavaScript is used in millions of Web pages to add functionality, validate forms, detect browsers, and much more http://www.w3schools.com/js/default.asp Accessed 20-11-2010), Perl, Python and ASP.NET are similarly languages that run within the web browser, that can be used used in web development to execute and interact with web services, with advantage to using APIs and webservices regardless of the language r platform used by the consumer of the Web Service. The whole exchange of machine readable data in this way is made possible by XML (eXtensible Mark-up Langauge, and it's various incarnations). Defining information as elements using XML, much in the same way HTML tags describe formatting of a webpage, allows information to be passed around without any ambiguity. XML will be described in greater detail my next post.

No comments:

Post a Comment