HTML
  Home arrow HTML arrow Page 2 - Hunting the Web Services at Amazon
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
HTML

Hunting the Web Services at Amazon
By: Ahm Asaduzzaman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 11
    2003-03-17

    Table of Contents:
  • Hunting the Web Services at Amazon
  • Writing Your Application
  • Walkthrough Example
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Hunting the Web Services at Amazon - Writing Your Application


    (Page 2 of 4 )

    What You Need To Do

    The PHP NuSoap class provides a clean and simple way to access Amazon product information using the Amazon SOAP APIs . You will need to install the NuSoap library on your machine. This library can be downloaded from here . Download the file nusoap.php. You will also need free developers token; get it from here , all you need is your email address. Following picture depicts the development process.

     


    Analyze Amazon Web Services

    If you are new to Web Services, read introductory articles here . Now, I assume, that you understand the benefits of Web services, lets take a closer look to Amazon.com’s WSDL (Web Service Description Language).

    This is nothing but a XML vocabulary and surprisingly simple, though it may look little bully at first look. With this document, we can view Web Service’s function, its location (end point) and special type. Click here to view the WSDL description for Amazon.com. 

    <xsd:complexType name="AuthorRequest">
        <xsd:all>
      <xsd:element name="author" type="xsd:string"
      <xsd:element name="page" type="xsd:string" />
      <xsd:element name="mode" type="xsd:string" />
      <xsd:element name="tag" type="xsd:string" />
      <xsd:element name="type" type="xsd:string" />
      <xsd:element name="devtag" type="xsd:string"
      <xsd:element name="sort" type="xsd:string" minOccurs="0" />
      </xsd:all>
      </xsd:complexType>

    First, look at the <xsd:complexType> tag. This tag allows Amazon to create new types that provide additional functionality or grouping. In this case, we have an object that stores “Author search” criteria. Each type within this object is a string type. In the above code snippet, the elements wrap to the following keyword data:

    Author – the author name used in this search
    Page – Which page of the search result you would like to see
    mode – A list of valid store
    tag – “Webservice-20” this denotes, that this is a web service call
    type – “lite” or “heavy”, this corresponds with the amount of data you want return
    devtag – Your unit token (a free token is available at Amazon.com web site)

    <message name="AuthorSearchRequest">
      <part name="AuthorSearchRequest" type="typens:AuthorRequest" />
      </message>
    <message name="AuthorSearchResponse">
      <part name="return" type="typens:ProductInfo" />
      </message>

    Another important element in the WSDL is the <message> tag; it provides information about the functions available from Web Services. In the above code snippet, the <part> element represents the parameters for the function named AuthorSearchRequest. You should also notice that we have two separate <message> elements, one named KeywordSearchRequest and the other AuthorSearchResponse. Request should be used when calling the function while response is used to provides the type returned from the function.
    By combining our <message> and <xsd:complexType> elements, we can understand the function and the parameters it requires.

    Write Your Application

    Here is the full set of method calls with brief description that you can make remote call from your PHP application:

     Function (Methods) and parameters  Description
     DoKeywordSearch ($Keyword, $Type = 'lite', $Category = 'books', $Max = DEFAULT_MAX)  Search for items (books, by default) matching the given keyword.
     DoBrowseNodeSearch ($BrowseNode, $Type = 'lite', $Category = 'books', $Max = DEFAULT_MAX)  Search for the items (books, by default) within the given Browse Node.
     DoAuthorSearch ($Author, $Type = 'lite', $Category = 'books', $Max = DEFAULT_MAX)  Search for items (books, by default) with the given author.
     DoASINSearch ($ASIN, $Type = 'lite')  Search for items with the given ASIN or ASINs. Supply a PHP array as the first argument to search for multiple ASINs.
     DoUPCSearch ($UPC, $Type = 'lite', $Category = 'music')  Search for item (music, by default) with the given UPC.
     DoManufacturerSearch ($Manufacturer, $Type = 'lite', $Category = 'books', $Max = DEFAULT_MAX)  Search for the items (books, by default) with the given manufacturer.
     DoActorSearch ($Actor, $Type = 'lite', $Category = 'dvd', $Max = DEFAULT_MAX)  Search for the items (books, by default) with the given manufacturer.

    Table 1: Amazon’s Web Services function list

    All parameters except the first are optional. $Type can be 'lite' or 'heavy'. $Category must be a valid Amazon category. $Max is the maximum number of results to return (10 is the default).

    The skeleton of our client code (pseudo codes) will look something like following:

    <?php
    If (!$_POST[‘query’])
    {
    //display form
     
    } else {
    //execute query at Amazon


    }


    As you can see, the script is split into two sections, one for the search form and the other for the search result. An "if" statement is used to decide which section of the script to execute.

    More HTML Articles
    More By Ahm Asaduzzaman


     

    HTML ARTICLES

    - Comparing Browser Response to Active Client ...
    - Testing Browser Response to Active Client Pa...
    - Active Client Pages: Completing the Code for...
    - ACP and Browsers: Setting up an Example
    - How Browsers Respond to Active Client Pages
    - Completing a Tree with Active Client Pages
    - HTML Form Verification and ACP
    - Building an ACP Tree
    - Completing an ACP 3D HTML Table Image Gallery
    - Building an ACP 3D HTML Table Image Gallery
    - A Multiple Page Image Gallery with Active Cl...
    - Building an Image Gallery with Active Client...
    - Concluding a Menu for All Browsers
    - A Vertical Menu for All Browsers
    - Downloading Long HTML Pages with ACP







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek