Amazon Web Services

ScanZoom lets you use mobile camera phones to launch services by taking photos of barcodes.


December 01, 2005
URL:http://www.drdobbs.com/cpp/amazon-web-services/184406352

December, 2005: Amazon Web Services

Ashish is the chief technology officer and Justin is a software engineer at Scanbuy. They can be reached at [email protected] and [email protected], respectively.


REST versus SOAP


ScanZoom is an application that lets you use mobile camera phones to launch services and applications simply by taking a photo of a barcode. For example, say you're shopping at Fry's Electronics and want to compare iPod prices with other retailers. You could take a picture of the barcode on the iPod packaging (or enter the barcode value manually) and ScanZoom finds out and reports on what that same iPod costs at competing retailers.

Developed at Scanbuy (where we work), ScanZoom can be installed by first downloading the application onto a PC from http://www.scanzoom.com/, and then installing it on mobile phones (via BlueTooth, infrared, WAP, or SMS), or by embeddable microchips.

In developing ScanZoom, we had two requirements that the data source needed to provide:

Because of the size of Amazon's product database and its vast amount of information, Amazon's freely available web service API was the first resource we turned to. In particular, Amazon's E-Commerce Service (ECS) provides access to all of the content on the product pages of the Amazon.com site in an XML format.

From our perspective, Amazon's ECS (http://www.amazon.com/aws/) revolutionizes what a web service can do for developers. The service gives you direct, real-time access to all of Amazon's features, including consumer reviews, new and used product listings from individuals and companies, and a list of similar products that can be purchased along with almost all category-specific details that you can imagine. This service let us take ScanZoom to the next level and link mobile phones with the power of Amazon.

Providing information that would not be readily available to users holding products in their hands was essential. If all we offered were those basic details, what good would the application be to the consumer? Users would be able to see most, if not all, of the basic information while scanning the barcode on the package. ECS provided us with extra information, which would be helpful to a consumer in making a decision while shopping. For example, many people read consumer reviews before selecting a product to purchase. Through ECS, we can offer shoppers quick access to this information so that they can read each and every review that Amazon has on a product. Shoppers can then make an informed decision without having to research the product before leaving home. The application is also able to show similar products that are offered so that consumers are able to see other options and read reviews on those items before making a decision.

Still, pricing is one of the main reasons that consumers shop the Internet. However, comparing prices requires research, and many purchases are impulse buys made while shopping for other items and no research has been done. Through our application, users can instantly gain access to not only the price that Amazon offers, but to the price that retailers in the Amazon network provides. Because many of these retailers (Target and Circuit City, for instance) have large retail stores, they can go to another retailer to make their purchase at a discount. Users can also save more money by buying used items through Amazon. The used item prices are shown on the handset, along with the seller's rating and a description of item quality and condition.

Specific product information is joined by the item's packaging information, such as DVD movie run time, CD release date and track listing, and the like. Having all of this information combined into one data feed made it possible for us to pull up all of this information with a single search. The process of integrating the web service into our current web application was also fairly simple because Amazon offers a WSDL that we are able to connect to inside our C#.NET development environment. Creating a reference in the project to the URL of the ECS WSDL is all it took to have access to all the data types and functions necessary to gather our product information. Example 1 is a sample connection and query that returns an Amazon Item data type containing all the products from the search, along with the relevant item information. That's all that's involved in fetching Amazon's product information.

This query is also very customizable. Because we are dealing with mobile devices with limited memory and bandwidth, we need to make sure that the page being retrieved by the mobile browser is as compact as possible. We are able to efficiently do that by limiting the searchRequest.ResponseGroup to an array of only the response groups that are necessary for what is being displayed on the phone. For example, if you only need to know the item's price from Amazon along with some basic item details (such as category), you can simply have the response group set to "Small" (also offered are "Medium" and "Large"). Those response groups contain an array of smaller response groups. Instead of picking "Medium" or "Large" when you need more than just the basic information, you call on only those response groups that are needed, such as the ones that are listed on line 6 in Example 1.

You can further reduce the time it takes to return data to the mobile handset by searching in exact categories with more exact search criteria. In Example 1 (line 8), we are using a Blended SearchIndex. However, you could specify Books or Movies instead. We don't use this query when doing the initial search based on UPC or ISBN, but when we are requesting the "Reviews" or "Similar Products," we use it to minimize the irrelevant results and make the data set smaller.

Most of the development we did to integrate ECS into our web application was as simple as Example 1. However, we did run into a snag here and there. For example, we needed to display products from different categories on the same page template. The item information that is returned in the Item data type from ECS has different names for item details depending on the item category. For instance, the artist of a CD would be reached from Item.ItemAttributes.Artist, while the writer of a book would be Item.ItemAttributes.Writer. To solve this issue, we find the Item.ItemAttributes.ProductCategory, then list the item details based on that category. This was the only issue that we faced and it was definitely not a major issue, just a small bump in the road.

Using ECS, our application offers users a mobile shopping and pricing guide that is simple and fast to use. Developing the solution was almost as easy and let us offer users something that they couldn't previously get on their cell phone without a lot of keyboard pecking and squinting at a small screen.

DDJ

December, 2005: Amazon Web Services

1  string subID = "<our subscription id>";
2  AWSECommerceService service = new AWSECommerceService(); 
3  ItemSearch itemSearch = new ItemSearch();
4  ItemSearchRequest searchRequest = new ItemSearchRequest();
5  searchRequest.Keywords = keywords;
6  string[] responseGroup = 
      newstring[]{"OfferFull","ItemAttributes","Reviews","Images"};
7  searchRequest.ResponseGroup = responseGroup;
8  searchRequest.SearchIndex = "Blended";
9 
10 ItemSearchRequest[] searchRequests = 
      newItemSearchRequest[]{searchRequest};
11 itemSearch.SubscriptionId = subID;
12 itemSearch.Request = searchRequests;
13 ItemSearchResponse response = service.ItemSearch(itemSearch);
14 Items info = response.Items[0];
15 Item[] items = info.Item;
16 return items[0];

Example 1: Sample connection and query that returns an Amazon Item data type.

December, 2005: Amazon Web Services

REST versus SOAP

The proliferation of web services has brought out an interesting focus on REST versus SOAP. Those in favor of REST argue for HTTP's built-in security (SSL). On the other hand, SOAP offers flexibility in delivery through other modes of transport by storing address information in the SOAP envelope. While Amazon ECS offers both scenarios to developers, we opted for SOAP because it provides consistency across different applications.

This feature was especially important in developing ScanZoom since the screen of the cell phone is limited in both size and resolution compared to that of typical displays. Because of this constraint, we couldn't simply redirect users to an HTML web page (such as Amazon's product pages) because navigating it would be nearly impossible. In addition, many of the stock web browsers available on mobile devices do not support the full HTML collection and require a special XHTML Mobile Profile compliant page. Because Amazon provides access to its information through XML, we were free to format its content in a way that made it simple for the end user to understand and navigate, even on primitive cell-phone browsers, while still allowing the functionality that one would expect with more advanced PDA-type handsets. ECS also let us handle browser-compatibility issues, increasing the number of handsets that we can support.

—A.M. and J.H.

Terms of Service | Privacy Statement | Copyright © 2024 UBM Tech, All rights reserved.