Has anyone managed to port this example to Flex 2?
http://jeff.mxdj.com/using_amazons_itemsearch_webservice_from_flex.htm
Here is my Flex 2 version with REST and SOAP requests :
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
height="600"
width="800">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.controls.dataGridClasses.DataGridColumn;
import flash.net.*;
private var subId:String = "blahblah"; // your
subscription id here
private function showRESTResult(event:Object):void {
items.dataProvider =
event.result.ItemSearchResponse.Items.Item;
}
private function showSOAPResult(event:Object):void {
items.dataProvider =
event.result.Items.Item;
if (!event.result.Items[0].IsValid) {
Alert.show(event.result.Items[0].Errors.Error.Code + " : " +
event.result.Items[0].Errors.Error.Message, "Error in SOAP Request");
}
}
private function showTitle(item:Object,
column:DataGridColumn):String{
return item.ItemAttributes.Title;
}
private function showAuthor(item:Object,
column:DataGridColumn):String{
return item.ItemAttributes.Author;
}
private function showBook(url:String):void {
navigateToURL(new URLRequest(url));
}
private function doRESTSearch():void {
var request:Object = new Object();
request.Operation = "ItemSearch";
request.SearchIndex = "Books";
request.Sort = "salesrank";
request.SubscriptionId = subId;
request.Keywords = searchTerm.text;
amazonRESTService.send(request);
}
private function doSOAPSearch():void {
var itemSearchRequest:Object = new Object();
itemSearchRequest.SearchIndex = "Books";
itemSearchRequest.Sort = "salesrank";
itemSearchRequest.Keywords =
searchTerm.text;
var search:Object = new Object();
search.Request = itemSearchRequest;
search.SubscriptionId = subId;
amazonSoapService.ItemSearch(search);
}
]]>
</mx:Script>
<mx:HTTPService id="amazonRESTService"
result="showRESTResult(event)"
showBusyCursor="true"
url="http://webservices.amazon.com/onca/xml?Service=AWSECommerceService"
useProxy="false" />
<mx:WebService id="amazonSoapService"
wsdl="http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.
wsdl"
result="showSOAPResult(event)"
showBusyCursor="true" />
<mx:HBox width="100%">
<mx:TextInput id="searchTerm" width="50%"/>
<mx:Button click="doRESTSearch()" label="REST Search"/>
<mx:Button click="doSOAPSearch()" label="SOAP Search"/>
</mx:HBox>
<mx:DataGrid
id="items"
width="100%"
change="showBook(event.target.selectedItem.DetailPageURL)">
<mx:columns>
<mx:Array>
<mx:DataGridColumn dataField="Title"
labelFunction="showTitle" width="400" />
<mx:DataGridColumn dataField="Author"
labelFunction="showAuthor" width="150"/>
<mx:DataGridColumn dataField="ASIN" headerText="ID"
width="75"/>
</mx:Array>
</mx:columns>
</mx:DataGrid>
</mx:Application>
The REST search version works well.
The SOAP version doesn't...
When analyzing the SOAP parameters in the HTTP request with ServiceCapture,
it does not send any "Request" parameter (only "SubscriptionId").
When I comment the line "search.Request = itemSearchRequest;", it correctly
sends a "Request" parameter (with a null value).
It looks like there is a conflict somewhere with the "Request" parameter?
Benoit Hediard
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/