Thursday, March 02, 2006

WAP Bookstore application


I publish the source code for myself as a reference when I need it anytime later. The application has Servlets as the main classes that serve HTML document to PC browser and WML document to mobile browser. Using REST connection over HTTP, the program communicates with Amazon Web Services everytime the user searches a book. As a response, Amazon returns an XML document that contains the book's details. I use XSL stylesheet to transform that XML document into HTML or WML format. The program identifies the request comes from which type of user (PC or mobile) by reading the HTTP user-agent request header.

This is the application Use-case main model diagram:

The program contains:

Sample book's details returned by Amazon. The request was based on the book's title:Fallen Angel and author:Don J. Snyder.

<?xml version="1.0" encoding="UTF-8"?><ProductInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xml.amazon.com/schemas3/dev-lite.xsd">

<Request><Args><Arg value="
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050225 Firefox/1.0.1" name="UserAgent"></Arg><Arg value="ZY1XY" name="RequestID"></Arg><Arg value="title:Fallen Angel and author:Snyder and keywords:Novel" name="***"></Arg><Arg value="us" name="locale"></Arg><Arg value="***" name="***"></Arg><Arg value="***" name="t"></Arg><Arg value="xml" name="f"></Arg><Arg value="books" name="mode"></Arg><Arg value="lite" name="***"
></Arg></Args></Request> <TotalResults>1</TotalResults>
<TotalPages>1</TotalPages>
<Details url=
http://***/
>
<Asin>0743422325</Asin>
<ProductName>Fallen Angel : A Novel</ProductName>
<Catalog>Book</Catalog>
<Authors>
<Author>Don J. Snyder</Author>
</Authors>
<ReleaseDate>01 November, 2003</ReleaseDate>
<Manufacturer>Washington Square Press</Manufacturer>
<ImageUrlSmall>http://images.amazon.com/images/P/0743422325.01.THUMBZZZ.jpg</ImageUrlSmall> <ImageUrlMedium>http://images.amazon.com/images/P/0743422325.01.MZZZZZZZ.jpg</ImageUrlMedium> <ImageUrlLarge>http://images.amazon.com/images/P/0743422325.01.LZZZZZZZ.jpg</ImageUrlLarge> <Availability>Usually ships in 24 hours</Availability>
<ListPrice>$12.00</ListPrice>
<OurPrice>$9.00</OurPrice>
<UsedPrice>$0.95</UsedPrice>
</Details>
</ProductInfo>



-----------------------------------------------------------------------------------

continue....