How to Use Amazon's ItemSearch Web Service From Flex
The Silverlight Flex language lets you create animations and real-time reporting for your website. You must incorporate the Amazon WSDL into your Flex project to display content from Amazon's Item Search Web Service, which is a service that connects your site to the large inventory of books sold on Amazon. After you integrate the WSDL, you can perform a simple search on the service to display a list of books.
Instructions
-
-
1
Open the Flex editor on your desktop and open the project in which you want to include the Amazon service.
-
2
Add the Amazon Web service WSDL. The WSDL is a file that defines all of the functions and properties of the Web service. Copy the following code to your page:
<mx:WebService wsdl="http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl" id="amazonService" result="showResult(event)" showBusyCursor="true"/>
-
-
3
Add a function that uses the Web service to search for a particular item or a list of items. The following code shows you how to set up a search:
<mx:Script>
function amazonsearch(){
var searchParams:Object = new Object();
searchParams.SearchIndex = "Books";
searchParams.Keywords = "search terms";
var search:Object = new Object();
search.Request = searchParams;
amazonService.ItemSearch(search);
}
</mx:Script>Replace "search terms" with the terms you want to use to find a list of books.
-
4
Add a button that runs the search query when the user clicks it. The following code adds a button to your form to perform the search:
<mx:HBox width="100%">
<mx:TextInput id="searchTerm" width="50%"/>
<mx:Button click="amazon()" label="Search"/>
</mx:HBox>
-
1