Home > SOA Tips > Guest Commentary > Support for RESTful Web services: Part 2, toolkits
SOA Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

GUEST COMMENTARY

Support for RESTful Web services: Part 2, toolkits


William Brodgen
02.07.2008
Rating: --- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


In the previous article I described how the creators of standards are coping with the industry interest in the REST (Representational State Transfer) style of Web services. I found both new approaches and adaptation of existing standards to include REST.

I find the same thing happening with developers of software toolkits widely used in distributed systems. That is to say, existing projects are adding REST interfaces in order to keep up with developer interest, and there are a few totally new tools. I was rather surprised to find that the latest version of a well known open-source Java Message Service (JMS) has added some REST related functionality.

Java Message Service
JMS is an example of message-oriented middleware" (MOM), one of the simplest ways to implement data exchange between loosely coupled distributed systems. The JMS API has changed little since the first release in 2001 because the basic ideas are so simple. A JMS server manages messages sent by "producers" and stored for subsequent asynchronous reading by "consumers." The server can provide for persistence so there is no requirement for producer and consumer to be connected to the network at the same time.

Each message is self-contained and consists of routing information plus a message body. The JMS server only pays attention to the routing information and ignores the message body, in contrast with the Javaspaces pattern of distributed systems where the content controls the fate of messages.

There are two basic messaging patterns, publish-subscribe and point-to-point message queue. Published messages can be read by all subscribers to a particular named topic. An example might be a price list copied by multiple clients in an organization. Subscribers do not have to be connected at the time a message is published if they have registered a durable connection to the topic.

Messages sent to a point-to-point message queue are consumed when read. There may be multiple consumers connected to a queue but only one will get each message so a queue is ideal for distributing work in a computation grid. Since both message queues and published topics are addressed by name, the REST style of addressing resources fits easily into the JMS addressing scheme.

The Apache ActiveMQ JMS Server
I installed the free download of the latest ActiveMQ build. The download is a very complete package. In order to experiment with the provided examples you only need a 1.5 or later Java SDK and the Ant build toolkit. The Jetty servlet container is included in the download so you don't need to install any HTTP server.

ActiveMQ has grown to be a powerful toolkit with many more capabilities than simple JMS support. For example, there is support for specialized serving of JavaScript scripts and handling Ajax requests.

Of greatest interest here are the examples of REST style web services. The demos include:

  • Reading data from a publish-subscribe stock price topic to create a stock portfolio display.
  • Sending a message with POST to a publish-subscribe topic or a point-to-point queue.
  • Reading from a queue with GET.

The way ActiveMQ has handled reading from a queue with GET illustrates an interesting problem. In strict REST style, a GET should not alter the resource, but JMS requires that reading a point-to-point queue removes the message. I suspect that retrofitting REST to other frameworks may encounter similar conflicts. Here is what the developers have to say about it:

Note that strict REST requires that GET be a read-only operation. So, strictly speaking, we should not use GET to allow folks to consume messages. Though we allow this as it simplifies HTTP/DHTML/Ajax integration somewhat.

As is typical of open source projects, the documentation provided with the download is relatively thin. However, the source, with typical Javadocs comments, can be downloaded and the project Web site has plenty of resources.

Restlet - a aew approach
As an example of a clean slate approach to RESTful Web services, we find the Restlet project. Restlet is a trademark of Noelios Consulting, the originators of the API. This open-source project is licensed under the Open Source Initiative Common Development and Distribution License. The first public release was in November 2005 and is currently at version 1.0.7, with a major revision to 1.1 in the works.

The Restlet developers feel that only a complete replacement of the servlet API can fully exploit REST concepts. For example, the servlet API assumption of one thread per request prevents use of Java's "NIO" non-blocking I/O classes and limits scalability. Use of the NIO classes permits more flexible connectors between computing components.

The Restlet examples are going to look very odd at first glance to developers used to the servlet API. For example, there is nothing comparable to the servlet Session. Fortunately, the recent book, "RESTful Web Services" by Leonard Richardson and Sam Ruby, contains examples of use of the Restlet framework to implement a service.

The downloadable Restlet distribution includes Java classes implementing the Restlet API and a reference implementation, called the Noelios Restlet Engine. This creates a complete Web server including efficient serving of basic static files. However, if you are already committed to an existing servlet engine such as Tomcat, an adapter to run Restlet applications is provided. Adapters are also provided to connect to an Apache Web server or Microsoft IIS.

What Next?
I will be looking around for other examples of both old frameworks with new REST features and completely new approaches. Perhaps I will find enough to make a part 3 article.

Resources

Discussion of the implementation of REST style in ActiveMQ.

The Java Community Process specification for JMS (JSR 914).

JMS with a SOAP Web Service

Open Source Initiative license conditions.


Rate this Tip
To rate tips, you must be a member of SearchSOA.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
The Web Services Advisor
Where does BPEL fit in?
Some notes on ESB configuration
Open source application development frameworks offer alternatives
What to expect with the new JavaScript standardization (ECMAScript 5)
Restlet framework wrestles RESTful Web applications
3 tips for choosing whether to use EGL
Use SoaML to facilitate Model Driven Architecture
Enterprise mashup patterns act as API enablers
XQuery learns to write using XUF
Descriptive Languages for RESTful Services

Guest Commentary
Get a grip on JavaFX 1.2 for Rich Internet Applications
On the road to SOA – Part 1, Boubez on early insights
On the road to SOA – Part 2, Governance is fundamental
SpringSource approach to adding enterprise class management and deployment features to Tomcat
Canonical Schema establishes interoperability: SOA Pattern (Week 6)
Legacy: Can't Live With It, Can't Live Without It
Review of protocols for cloud services - Part 1
SOA and TOGAF: A Good Fit?
Using atomicity to gain SOA granularity
Too Many Servers: A Case for Enterprise Architecture and TOGAF 9

Representational State Transfer (REST)
IBM REST engine taps into Microsoft-backed OData protocol
Restlet framework wrestles RESTful Web applications
Mulesoft architect talks REST, ESBs
How do I balance throughput requirements and interoperability?
IBM Sabbah's say on REST for collaborative ALM
Report on REST- REpresentational State Transfer
Are tools available to work with OSGi today?
Expert Query: What is the difference between RESTful transactions and Web Services transactions?
Progress/Actional SOA diagnostic tool builds on Mindreef purchase
SOA goes beyond 'rip, replace, repeat'

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
REST  (SearchSOA.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



SOA Trends and Strategy - SOA Education, SOA Development, SOA Implementations
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2001 - 2010, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts