Posted by stoicflame
on January 9, 2008 at 11:33 AM PST
This is the first of a two-part tutorial that will walk you through the development of a Web service API that bundles a bouquet of remoting technologies: SOAP, REST/XML, JSON, GWT-RPC and even AMF (for all you Flex developers). Bring your favorite IDE and join the fun!
So you've got a web application that needs to expose a Web service API. Maybe you're going to be writing a
href="http://en.wikipedia.org/wiki/Rich_Internet_application">Rich Internet Application (RIA) using
href="http://en.wikipedia.org/wiki/Adobe_Flex">Flex or some
AJAX Framework . Or maybe you'll be developing a desktop application that needs to interface with your online data. Or perhaps you've got a few business
partners that want to integrate with your application.
Whatever the reason, you need a solution that not only fits your client-side requirements, but one that is also easy to develop, easy to debug, easy to
maintain, and easy to enhance. Don't be too hasty with your choice of a Web service implementation technology.
href="http://weblogs.java.net/blog/stoicflame/archive/2007/10/why_roi_vs_soi_1.html">REST is not always the best answer. It might
be, but not always. Take some time to research your needs, gather your requirements, and look at other remoting technologies that are available. Then decide
what you need.
This is the first part of a tutorial will walk you through developing a Web service API that could meet the requirements of all of the above-mentioned use cases. For the sake of
clarity and brevity, we'll keep the operations simple, but by the time we're done, we'll have a fully-functional Web service API that exposes a bouquet of
endpoints: SOAP , REST /XML,
href="http://www.json.org/">JSON, GWT -RPC, and even
href="http://en.wikipedia.org/wiki/Action_Message_Format">AMF (for all you Flex developers). In Part II of this tutorial, we'll prove out the Web service API by building a rich AJAX
application with an embedded Flash component that accesses it.
By the end of this two-part tutorial, we'll have established a good custom-fit Web service development
process for maintaining your Web service API in your favorite development environment.
For those of you who would like to see the example code on your local filesystem, you can check it out of SVN at http://svn.codehaus.org/enunciate/trunk/enunciate/src/samples/addressbook/ .
Step 1: Create Your Project
We will be exposing a Web service API for an address book application. We will be using Maven 2 and
href="http://enunciate.codehaus.org">Enunciate 1.6 to build and package our
application. (Note that we could also use Ant to build the application, but Maven will get us started more quickly.)
We'll label our application