Posts Tagged ‘Add new tag’

REST Service Implementation using HTTP – Cross Domain Request

Sunday, March 29th, 2009

By Phavanhna Douangboupha, 03/29/09

The three main basic ideas of a REST process are to process a client request, to response to the request, and return a result/data in XML format according to the request.

Two techniques that can be used are getting parameters from client through a URL query string and the use of HTTP methods. The first technique is easier to implement compared to the second technique. The main disadvantages of the first technique include the size of the URL string, the maximum length of the URL string consisting of query parameters, and a possible negative side effect. The first limitation, the size of URL string, can be overcome by using POST method instead of GET method for a client request. However, POST and GET methods should be applied according to a specific task (see the blog on Creating REST Web Service for more detail). Consequently, the HTTP methods are a better solution for REST service.

I have already talked about how to implement a REST client using a URL query string from my previous post, now I will talk about how I implement a REST service for the cross server client request using HTTP methods.

For this exercise, a database server, a web host server and a web client server are assigned in different machines and hosted by different domains. The database server is hosted at STREAMER. The web host server is hosted by CHW domain and finally the demonstrated web client request comes from GIBSON domain (Figure 1 shows system architect for the REST cross domain service). STREAMER is a house to MySQL database which is hosted in a different domain from the web server.

System architect for REST cross domain service
System architect for REST cross domain service

Figure 1: System architect for REST cross domain service

GIBSON is used as a demonstration client to request data from another domain (CHW). The four main files implemented here are a normal HTML file (index.html), a JavaScript file (client_local.js), and two php using cURL libraries files (getclient_chw.php and postclient_chw.php). The Javascript file is used to implement Ajax to send a request and to receive responded data sent back by a server asynchronously. The data is displayed on the HTML file. The JavaScript file uses HTTP request object to send a request to either getclient_chw.php (”How Many Users?” in the database) or postclient_chw.php (”Add New User” to the database). getclient_chw.php and postclient_chw.php use cURL libraries to set up a HTTP request where getclient_chw.php uses the GET method to request to get data from a server and postclient_chw.php uses the POST method to request to post data to a server (please see table 1 for the correspondent HTTP methods to the database query). Both of the files make a request to process data with the web server on CHW. The client side has no relation to the database server on STREAMER and it only sends a HTTP request which will later be checked by the web server.

Use Gibson to act as a client to make REST request​ (Figure 2) - http://people.rit.edu/~pxd8840/restclient/index.html . As you click one of the two buttons – “How Many Users?” (HTTP GET) and “Add New User” (HTTP POST), you will see that the displayed results are updated asynchronously. These are done via Ajax using REST service to perform a cross-domain request instead of the <script> tag hack solution as mentioned from my previous post.

index.html, client requests on GIBSON

index.html, client requests on GIBSON

Figure 2: index.html, client requests on GIBSON

On the web host server (CHW), there are two main files – rest_database.php and ConnectDB.php. ConnectDB.php is an Object Oriented PHP class that contains methods to connect to the database and the required methods to process or retrieve data from STREAMER database server. The rest_database.php file also contains all the logic check method that received from a client. The rest_database.php file is used to check what kind of request being made if it is a HTTP GET request or a HTTP POST request. According to the request, it retrieves data from the database. Then it creates XML responses to the client.

Table 1: HTTP method, REST action, and SQL command for a client request

HTTP Request Method REST Action SQL database command Description
GET GET SELECT Search/Request for
data (getdata)
POST POST INSERT Add/Insert new data
(postdata)

List of files

Client Side

  • index.html
  • client_local.js
  • postclient_chw.php
  • getclient_chw.php

Server Side

  • rest_database_php
  • ConnectDB.php class code on the server side contains database connection and database process methods

References:

Links to other blogs in this project

WIMP is Dying, Long Live WIMGi

Wednesday, March 4th, 2009

From WIMP to WIMGi

The WIMP (”Windows, Icons, Menus, Pointing-device”) formulation for human–computer interaction design has lasted a long time (it was coined by Merzouga Wilberts in 1980). The phrase has become perceived as pretty much a synonym for “desktop GUI”, but I think it is dying (or at least past it’s prime). I think the death of WIMP will be a result of two things: the spread of touch-gesture oriented handheld devices, and the emergence of practical & relatively inexpensive multi-touch screens (see especially the work of Jeff Han).

So, what is taking the place of WIMP? I think we are entering the Age of WIMGi (rhymes with “whimsy”): Windows, Icons, Menus, Gesture-interface. Why is WIMGi taking hold so strongly, and what is so different about it that we need a new acronym?

New Paradigms Require New Labels

Labels have symbolic power, and a new way of thinking about the “palmtop” and “desktop” environments requires a new label. A pointing device like the “mouse” is radically different than the gestures of the human hand-and-fingers. A mouse has one on-screen representation (the “pointer”), while fingers (plural) may require a different on-screen representation and definitely require different responses (”event handling”) from a computer.

WIMGi is a new paradigm for human computer interaction; it requires new thinking about how people will get work done, and about what operations it is possible for them to command easily. In the “palmtop” environment, WIMGi is perceived by users as “more natural”. In the “big screen” environment, WIMGi seems to require more work getting “used to it”.

Big-Screen Multi-Touch

Many people were amused to note the number of “giant multi-touch video walls” appearing on television during the 2008 Presidential election. I was interested to observe that correspondents had trouble “getting used to using it” (on the physical level), and that producers had trouble figuring out how best to use such displays (on the information-transmission level). So many shows used these devices simply “because they were sexy and new”, that a range of spoofs emerged like one segment in this “Saturday Night Live” program:

Palmtop Device Multitouch

On the other hand, even simple 2-fingered stretch/shrink gestures are “understood” almost immediately by people using “palmtop” devices. I think palmtops, laptops, and architectural-drawing-stand-like surfaces are probably the easiest venue for WIMGi to take hold within, as the scale and the gestures “just seem natural” to users. I think it will take a bit longer for big-screen WIMGi to take hold.

Just as many people had a somewhat steep learning curve when first introduced to computers with pointing devices, I think many people will have a harder time learning to use big-screen WIMGi computers than palmtop WIMGi devices. Who among us has not performed multi-finger gestures on a small scale, like on the palm of your other hand? Multi-finger/multi-hand gestures “writ large” on a wall-sized screen may take longer to learn.

What do you think of all this? Critical thinking, comments, new ideas are what I am after here. And so I repeat:

WIMP is Dying, Long Live WIMGi

Location Tracking Techniques

Saturday, January 31st, 2009

by Phavanhna Douangboupha

This blog contains information about some of the current practices in location tracking technologies. It mainly discusses the three common methodologies – GPS, Cell Towers, and Wi-Fi positioning service. The blog is a part of the ongoing investigation for the proposed capstone project on Web-based resource tracking during a disaster or crisis situation.

In general, there are four geo-location methods including triangulate, associate, geo term extraction, and data entry or geo-coding. The Global Positioning System (GPS), Cell Towers, and Wi-Fi positioning service (WPS) are the three well known triangulation techniques to identify a mobile device geo-location. GPS and Cell Towers are based on triangulation to identify an object position by using the location of known objects.

To put a location on a map, the geo-coding position technology relies on getting a location of an object via a meaningful X, Y coordinate or a latitude and longitude coordinate. In fact any available mapping tool such as Microsoft live search maps, Google maps, and Yahoo maps use the coordinate system to identify a requested location.

GPS relies on satellites that send microwave signals information back to the earth. The information is a navigation message of each satellite’s position and time. An object location is calculated by GPS receivers by the use of triangulation and the signal information provided by at least three satellites in order to determine an object’s location and four satellites for greater accuracy. The use of fourth satellite enhances the accuracy in the order of nanoseconds. GPS receivers compare the time difference between the arrival of satellite signals to tell the position. At least three satellites are needed in the calculation for an accuracy result. The first satellite provides a possible location of an object narrowed down to the surface of a sphere. The position is recorded as a radius equal to range 1. On the same token, satellite number two provides confirmation that the object is located within the first sphere (as located by the first satellite). Satellite number two provides an additional position circle of a radius range 2. The first and second satellite indicate that the object is positioned between the intersection between their two spheres – sphere one and sphere two. Finally, the third satellite shows a third sphere of radius range 3 for the positions. The object position is the intersect location of the three spheres. Finally, the fourth satellite is used to confirm the location and hence provides the time reference.

A GPS-enabled device provides geo-code location accuracy about 1 to 5 meters. Despite the fact that GPS system is widely used with many position tracking systems, it does come with some drawbacks. GPS does not work within indoor environment positioning and it requires costly power-consumption on mobile devices. In addition, not all mobile devices are GPS-enabled.

Another solution for location finding is the Cell Tower technique. Similar to GPS system, it requires at least three different cell towers within range of the device to calculate an object location for a high accuracy result. Otherwise, at least two cell towers are required. Each cell tower ,with a unique cell identifier, returns a positioning data to a requested mobile phone. Each mobile phone constantly pings a signal to nearby cell towers to get the cellular radio signal and hence some mobile phones also require costly power-consumption just like in the GPS  positioning techniuqe. Having data from all the cell towers, an algorithm can be used to calculate a final location of the mobile phone which lies in the middle. The advantage of cell tower triangulation technique is that is available for all mobile phones that have registered service providers . In addition, cell towers can be set up to send signal to mobile devices. Unlike GPS, cell towers will work in both indoor and outdoor environment. The accuracy of a position allocation depends on the density of cell towers in the area.

Wi-Fi Positioning Service (WPS) is the least accurate technique for location finding among the three techniques (GPS, Cell Towers, and WPS). IP address from a mobile device Wi-Fi connection is used to get a guessed location back from a service provider database such as Google map using API. Some of the available and well known mobile device location locator technologies are Google gear (Google map version for a mobile device), iPhone Core Location, and Navizon. Google mobile map and Navizon peer-to-peer wireless positioning tools  make the use of their massive data collection to provide a best guessed location for a device without GPS-enabled and for thoser devices that can not communicate with cell towers.

Google gear uses all three triangulation technologies to get the best accurate result. Google gear is compatible with many mobile devices including Windows Mobile, and Android. On the other hand, Core Location is another tool specifically programmed for iPhone. Apart from Google gear and iPhone Core Location, Navizon is another map locator tool. Navizon is free for a cellular enabled device, with some limitations, using cell ID positioning. However,  it is not free for a Wi-Fi or cellular enable device using cellular and Wi-Fi triangulation. Navizon database collects geo-coding data from registered users or devices with GPS-enabled. These data is collected and used as a virtual GPS. The tool uses the bank of data as a reference positioning point to locate a mobile device geo-location.

Another alternative technology is a tool so called PhoneGap that utilizes web application technology and Objective-C core features available on three mobile devices – iPhone, Android, and Blackberry.

References

  1. Bellavista, P., & Corradi, A. (2007). Mobile Middleware for Location-Dependent Services. In The Handbook of Mobile Middleware. USA: Auerbach Publications
  2. Berka, J. (2008, January 22). PhoneGa tool provides JavaScript access to iPhone features. In PhoneGap tool provides JavaScript access to iPhone features - Ars Technica [Internet Article]. Retrieved January 31, 2009, from
    http://arstechnica.com/apple/news/2008/10/
    PhoneGap-tool-provides-javascript-access-to-iphone-features.
  3. B’Far, R. (2005). Mobile Computing Principles: Designing and Developing Mobile Applications with UML and XML. United Kingdom: Cambridge University Press.
  4. Google. (2008). Services – Google Maps API – Google Code. In Google Maps API [Google Maps API Reference]. Retrieved November 9, 2008, from Google Web site: http://code.google.com/apis/maps/documentation/
    services.html#XML_Requests
  5. Google. (2009). Geolocation API. In Geolocation API – Gears API – Google Code [documentation]. Retrieved January 31, 2009, from Google Web site: http://code.google.com/apis/gears/api_geolocation.html#getCurrent
  6. Katsaros, D., Nanopoulos, A., & Manolopoulos (eds), Y. (2005). Location-Based Services. In Wireless Information Highways (section iv – location-based
    services). United States of America: Idea Group Publishing . Retrieved
    November 6, 2008
  7. Mallick, M. (2003). Mobile and Wireless Design Essentials. Indianapolis,
    Indiana, USA: Wiley Publishing. Retrieved November 8, 2008
  8. Mark, D., & LaMarche, J. (2009). Where Am I? Finding Your Way with Core
    Location. In Beginning iPhone Development: Exploring the iPhone SDK (pp. 429-439). USA: Apress
  9. Mexens. (2005-2008). How it works. In Peer-to-peer wireless positionin [product description]. Retrieved January 31, 2009, from http://www.navizon.com
  10. Olla, P. (2008). Global Navigation and Satellite Systems and Services. In
    Commerce in Space: Infrastructures, Technologies, and Applications
    (chapter v). USA: IGI Publishing. Retrieved November 8, 2008
  11. Wu, S.-L., & Tseng, Y.-C. (2007). Wireless Ad Hoc Networking-Personal-Area, Local-Area, and the Sensory-Area Networks (S.-L. Wu & Y.-C. Tseng, Eds.). USA: Auerbach Publications. Retrieved January 30, 2009

Links to other blogs in this project

Web-based resource tracking system implemented on a mobile device

Wednesday, October 29th, 2008

by Phavanhna Douangboupha

The objective of this project is to develop a prototype for an easy to use web-based resource tracking system implemented on a mobile device. It provides real time data to a decision maker so that he/she can effectively and efficiently monitor resources and access the situation accordingly. By the same token, emergency personnel (e.g. a doctor or a police man) has the advantage of system auto login without manual report upon their arrival to an affected location. The system architecture of the web-based resource tracking during a disaster or crisis situation can be seen below in Figure 1.

System architecture of Web-based resource tracking during a disaster or crisis situation
System architecture of Web-based resource tracking during a disaster or crisis situation

Figure 1: System Architecture of Web-based resource tracking during a disaster or crisis situation

Resources are, a human resource (e.g. a doctor, a policeman), a moving resource (an ambulance, a police car), and a building resource (e.g. a hospital).

The prototype includes three main applications – position tracking, resource management, and identity manager modules.

The resource management system consists of emergency classification, search, and alert systems. The project aims to design an easy to use user interface for the system so that users and decision makers can get to important information as quickly as possible. One of the solutions to such an objective is to have a classification of emergency combined with a recommendation system. The application utilizes the pre-existing data to recommend resources (what are required resources and their locations) for a certain situation such as flooding. Apart from the recommendation system, the system offers another search option, nearest search option, for users to search for required resources for the crisis that they have to manage.

The identified needed resource shall be alerted by the system. For a moving resource such as a doctor or an ambulance, the system should automatically provide routing or direction information to his/her GPS-enabled device. This functionality links to the position tracking application.

The second application is the position tracking application that consists of real time location update, routing, and the time statistic module. As a doctor responds to the system alert, his/her GPS enabled device will automatically send his current geographic X, Y coordinate location in thee form of an XML file. The XML file also includes the login id which is the unique device id. Before being passed through the network, the XML file is encrypted and only the system can decrypt the information (the identify manager module). As each resource travels toward the site, the decision maker will have a virtual map showing real time information about the resources. In addition, the system shall be able to provide a report on number of resources at each near by location. The routing information and the estimate time statistic prediction on when each resource will reach the site will also be an option on the decision maker’s screen. Using API technology, a virtual map is requested from a map server.

The system will make the use of the REST web-service to bridge the connection between the server and clients. The REST web-service and the WWW solution for the prototype are selected to avoid certain mobile specific standards. REST provides a solution for the mobile device system to interface with the system in manageable lightweight implementation. Since, REST utilizes URI namespace technology, it makes the application scalable and the data can be easily shared with different servers. In addition, REST uses HTTP and XML solutions and hence it is well understood by firewalls and security administrators.

Links to other blogs in this project