| By Yakov Fain | Article Rating: |
|
| January 15, 2008 07:30 AM EST | Reads: |
14,572 |
Now we need to call the operation KeywordSearchRequest providing the data according to the KewordRequest format.
2. Call the Web Service
var ws = com.farata.jsfx.WebServices("MyWebService");
Add the Web Service operation result listener.
ws.addEventListener("serviceresult", onXmlResult);
Prepare the arguments for the call (i.e., as an XML object) to find books that have the work AJAX in their titles:
Var args = '<m:KeywordSearchRequest xmlns:m="http://soap.amazon.com">'
+ ' <KeywordSearchRequest>' + '<keyword>AJAX</keyword>'
+ ' <page>1</page>' + '<mode>books</mode>'
+ '<tag>D3HW0PG66IPLAM</tag>' + '<type>lite</type>'
+ '<devtag>D3HW0PG66IPLAM</devtag>' + '<sort></sort>'
+ '<variations></variations>' + '<locale></locale>'
+ '</KeywordSearchRequest>' + '</m:KeywordSearchRequest>';
Call the "KeywordSearchRequest" Web Service operation.
ws.callService("Amazon", "KeywordSearchRequest", args);
Later in this article I'll show you how to pass the operation's arguments as a JavaScript object instead of XML. Now the data from Amazon comes back and WebService.swf will get something like this:
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:amazon="http://soap.amazon.com"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body>-<namesp1099:KeywordSearchRequestResponse xmlns:namesp1099="http://soap.amazon.com">
<return xsi:type="amazon:ProductInfo">
<TotalResults xsi:type="xsd:string">355</TotalResults>
<TotalPages xsi:type="xsd:string">36</TotalPages>
<Details xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="amazon:Details[10]">
<Details xsi:type="amazon:Details">
<Url
xsi:type="xsd:string">http://www.amazon.com/gp/product/0596101996%3ftag=D3HW0PG66IPLAM%26link_
code=sp1%26camp=2025%26dev-t=D3HW0PG66IPLAM</Url>
<Asin xsi:type="xsd:string">0596101996</Asin>
<ProductName xsi:type="xsd:string">JavaScript: The Definitive Guide</ProductName>
<Catalog xsi:type="xsd:string">Book</Catalog>
<Authors xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[1]">
<Author xsi:type="xsd:string">David Flanagan</Author>
</Authors>
<ReleaseDate xsi:type="xsd:string">17 August, 2006</ReleaseDate>
<Manufacturer xsi:type="xsd:string">O'Reilly Media, Inc.</Manufacturer>
<ImageUrlSmall xsi:type="xsd:string">http://ec1.images-amazon.com/images/I/11G8BIrxn7L.jpg</ImageUrlSmall>
<ImageUrlMedium xsi:type="xsd:string">http://ec1.images-amazon.com/images/I/21yLdMet2BL.jpg</ImageUrlMedium>
<ImageUrlLarge xsi:type="xsd:string">http://ec1.images-amazon.com/images/I/51OY5KP5ydL.jpg</ImageUrlLarge>
<ListPrice xsi:type="xsd:string">$49.99</ListPrice>
<Availability xsi:type="xsd:string">This item is currently not available.</Availability>
<UsedPrice xsi:type="xsd:string">$18.49</UsedPrice>
</Details>
...
As you can see, there is 355 AJAX books that can be returned as 36 pages, and Amazon has returned the page number one as was requested in the argument object. Parsing this XML will be automatically done for you by the WebService.swf component that will turn it into an object for easy access via dot notation.
A Mini-Tutorial on E4X, a Standardized Processing of XML
Working with XML (SOAP)-based Web Services in AJAX isn't easy: each
browser handles XML differently. But consuming Web Services with AJAX
can be fun if you delegate XML processing to our WebService.swf
component that engages E4X.
In Figure 3 you'll see how ActionScript 3 (we used it in creating WebService.swf) can work with any XML source (i.e. SOAP) using familiar dot notation. This is an example from ActionScript documentation and will give you a feeling of the ease of dealing with XML in ActionScript (for a more detailed explanation of E4X go to Click Here !.
Published January 15, 2008 Reads 14,572
Copyright © 2008 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Yakov Fain
Yakov Fain is a Managing Director of Farata Systems, consulting, training and product company. He has authored several Java books, dozens of technical articles. SYS-CON Books released his latest co-authored book , Rich Internet Applications with Adobe Flex and Java: Secrets of the Masters in Spring 2007. Sun Microsystems has nominated and awarded Yakov with the title Java Champion. He leads the Princeton Java Users Group. He is an Adobe Certified Flex Instructor. Currently Yakov works on the book for O'Reilly "Enterprise Application Development with Flex". He twits at twitter.com/yfain.
- Kindle 2 vs Nook
- Cloud Computing on Gartner's Top 10 List and SYS-CON Events' 2010 Calendar
- Confessions of a Ulitzer Addict
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Moving Your RIA Apps into the Cloud: Seven Challenges
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Windows 7 – Microsoft’s First Step to the Cloud
- Ulitzer Provides a Powerful Social Journalism Platform
- Jill Tummler Singer, Deputy CIO of CIA, Keynotes at GovIT Expo
- Open Source Mobile Cloud Sync and Push Email
- Kindle 2 vs Nook
- The Difference Between Web Hosting and Cloud Computing
- Cloud Computing on Gartner's Top 10 List and SYS-CON Events' 2010 Calendar
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- Confessions of a Ulitzer Addict
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- My Thoughts on Ulitzer
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- US Post Office Hops a Ride on NetSuite’s Cloud
- Moving Your RIA Apps into the Cloud: Seven Challenges
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Building a Drag-and-Drop Shopping Cart with AJAX
- What Is AJAX?
- Google Maps! AJAX-Style Web Development Using ASP.NET
- Flashback to January 2006: Exclusive SYS-CON.TV Interviews on "OpenAjax Alliance" Announcement
- AJAXWorld Conference & Expo to Take Place October 2-4, 2006, at the Santa Clara Convention Center, California
- AJAX Sponsor Webcasts Are Now Available at AJAXWorld Website
- How and Why AJAX, Not Java, Became the Favored Technology for Rich Internet Applications
- "Real-World AJAX" One-Day Seminar Arrives in Silicon Valley
- AJAXWorld University Announces AJAX Developer Bootcamp
- AJAX Support In JadeLiquid WebRenderer v3.1
- Where Are RIA Technologies Headed in 2008?
- Struts Validations Framework Using AJAX




































