Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Integrating AJAX Clients and RESTful Web Services : Page 3

The integration of AJAX clients and RESTful web services results in powerful yet straightforward service-oriented web applications.


advertisement
Integration Challenges
Few technologies fit as well together and simultaneously provide developers with such richness of choices as RESTful web services and AJAX. However, even two services working in such harmony present a few challenges that you need to understand.

Weak Typing
As already mentioned, RESTful web services are flexible in the formats they use for the resource representation. You have complete freedom to present service results any way you choose, but that freedom requires significant diligence and attention to how you specify and change interfaces (e.g., a rigorous change-control process). Make sure each RESTful service is amenable to well-defined schema (regardless of the format) and for the sake of quality assurance carefully monitor the use of schemas for the services.

Service Contracts
The core ideas of RESTful web services are that resources are represented as URLs and consumers of those services can manipulate the services through HTTP methods. With lo-REST (GET and POST only) there is not much need for concern. Service clients can read the state of the resource only via GET and make updates to it only via POST.



With hi-REST services however, clients can create new resources using PUT method and delete them as well. For example, in the previously cited online shipment-tracking service (see article for reference) AJAX clients can create new shipments and assign unique shipment IDs to them, as well as delete them. In a massively distributed web environment, assigning that level of control to an AJAX client can be quite a challenge.

So can you trust web clients to perform operations as critical as resource creations on the fly? My experience suggests you can, but you must have a strong understanding of the environment in which the application is running, the business and technical contracts between the clients and the services, and the business rules related to governing the contracts. While banks won't allow customers to assign account numbers to their newly created accounts, an internal application for shipment tracking that is well integrated with internal supply channels and all the rules governing the shipment-creation process could create new shipments. It could put (with PUT) the shipment info to the RESTful service that holds the new shipment's ID, which the AJAX application would dynamically assign.

A Synergy Between Power and Simplicity
As cliché as it may sound, "match made in heaven" naturally comes to mind when speaking of RESTful web services and AJAX. Immediately upon seeing these two technologies, I was attracted by their potential synergy. Looking at the numerous examples provided by web innovation powerhouses such as Google or Amazon, as well as by doing my own work, I realized that these two technologies are some of the most powerful and at the same time simplest ways to build lean, flexible, and service-oriented web applications.

This article reviewed the essential aspects of integrating these two technologies to share not only the techniques and technology choices involved in the integration process but also the benefits of this simple, straightforward approach.



Edmon Begoli a software architect with 14 years of professional experience on large commercial and federal software projects. He is a member of the R&D staff at Oak Ridge National Laboratory.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap