Library Technology Reports www.techsource.ala.org May—June 2006 19 cult cial for cial for rst set up rst liates. An individual or business The mechanism that expanding its Amazon uses for fi one must to begin using AWS, In order functionalityThe core of Amazon.com can be pro- extensive tools and documentationAmazon offers text,In the construct I’ll following a very simple ex- each sale. This arrangement has proven to be benefi has proven each sale. This arrangement both and its Amazon affi or its electronic own set up his, her, easily store- can fairly the capabilitiesfront; e-commerce this features storefront diffi more be much by Amazon, which would developed independently. to create and expensive online-business activities services. Using on Web is based technologiesWeb-service described in this report, Amazon techni- to Amazon’s access provide ServicesWeb (AWS) cal infrastructure. can be implemented using either AWS the but implementations majority or REST, of AWS SOAP the REST approach. simpler follow the registered, user will account. Once developer an AWS to a subscription ID, which will be used as a key receive services. of the Many Web Web gain access when invoking although free, services by Amazon can be used for offered fees. pay-per-use paid subscriptions or involve some require grammatically accessed through the E-Commerce Amazon use of ECS, Service for (ECS). Amazon does not charge though some restrictions information how regarding apply be used and theretrieved Amazon in thisfrom may way of transactionsnumber performed per second. (The WSDL Services[Web Description that Language] describes the at: http://webservices.amazon.com/ECS is available AWSECommerceService/AWSECommerceService.wsdl.) (http://aws.amazon building applicationsfor using AWS and other of books also a number re- are .com). There extensive information that provide available on sources implementing applications based on AWS. Serviceample that use of the makes Amazon Web (see liates ex- and partners. For

eal-world Web services will be examined in this Web eal-world This section technicalchapter. than is a bit more other parts of the report, but nontechnical readers Chapter 2 Chapter Amazon.com has grown to be one of the to be one of suc- most Amazon.com has grown should not be intimidated by the code listed programming should be able to in the nonprogrammers examples. Even understand the trying gist of what these are programs to on the grasp a keen accomplish without to have having (I ask that reading language. programmers programming this report with to bear unsophisticated my programming write would style; much programmers experienced more elegant code than efforts.) admittedlymore my awkward Amazon Web online Amazon, one of the popular commercial most interface a Web-service businesses, offers that provides The possibilities of interesting range a number features. the out of simple queries from Amazon catalogs to full- sites that Web operate e-commerce in partnershipedged fl liates with Amazon through the Amazon affi company’s program. es- quickly The company cessful businesses on the Web. tablished buying books on itself for as a popular source other and has expanded to sell many the types Web of products. In support of its busi- extremely high-volume a sophisticated,ness, Amazon has developed scaleable, and technology infrastructure.reliable its On Amazon is own, extremely successful, but an important part of its business strategy the efforts its company’s involves beyond to go affi direct sales and to include ample, Amazon allows otherample, Amazon allows individuals and organizations use of itsto make infrastructure to sell their products and a small commission on services it receiving for in return R Amazon and Amazon Examples of Web Services of Web Examples 20 Library Technology Reports www.techsource.ala.org May—June 2006 tions available for setting upWeb availabletions for pages setting andusersessions func- which providesome subroutines, somegeneral utility general components. the cal individualsunderstand appendix 4. invokes Web script, itproduces the this page shown in .pl?Author=Marshall%20Breeding. WhenaWeb browser URL:www.family-photos.info/amazon-web-service in the tosearch ispassedonas aparameter author of the confi programs.gured Thevalue CGI-style toexecute onaWebelements page. response, anddisplay selected service query, parsethe requestto sendaservice toAWS, anauthor toperform a Web-service client,aSOAP whichisused interface, Perl implements the script that Appendix 3illustrates Building aWeb-Service Client book. the “Hack88: Program AWS SOAP::Lite andPerl,” with in The following exampleisloosely basedonaprogram, AWS with is cations ● ● ● ● components: following ofthe examplesconsists for the The platform whichIammost comfortable. onewith itisthe son than Perlwill usethe programming language, rea- for noother few linesofprogramming—to results. display the todynamically a asearch execute tions onAmazon—with AWSappendix 3).Theexamplewillexplainhow the func- http://aws.amazon.com Amazon Web Services AWSECommerceService/AWSECommerceService.wsdl http://webservices.amazon.com/ Amazon E-CommerceService First, appendix 5 illustrates the code that “calls in” codethat the First, appendix5illustrates Breaking itdown may into steps alsohelpnontechni- that’s server onthe This script resides inadirectory A good resource for guidance indeveloping appli- XP Professional. componentofWindows comesasanoptional server (IIS)v5.0.ThisWeb Server Information The The SOAP::Lite Perl module;and andservices); ucts available andsellsprofessional programming prod- makes ActivePerl freely ActiveState .activestate.com] Inc., www Software, [available from ActiveState The Perl programming language. (IwilluseActivePerl fessional; Windows running XPPro- server An Intel-based report, examplesinthis other This, andmost ofthe Amazon Hacks byPaulBausch.

with this URL:http://api.google.com/GoogleSearch.wsdl. this with fi The WSDL APIsatwww.google.com/apis/index.html. its eachrequest.passed with Googleprovides on information you must create aGoogleaccount andreceive is akey that fetching acachedpage. requesting and results, aspellingsuggestion, ceiving the including asearch executing on Googleandre-services, accessseveralcan beusedtoprogrammatically different resources inamodelfor Web TheGoogleAPI services. Google alsoprovides aSOAP-based APIfor accessingits The GoogleSearch API calleda sources.from multiple Thisisoften examplemightinvolveinteresting usingWeb services onesource, displays from just butamore the content that might need.Thescript inappendix3buildsaWeb page returned hisorherapplication form inwhatever content userisnow abletousethe the pointisthat the strated, demon- interface simplistic the than looks much better Amazon.comcertainly Although inaninterface. mation from agiven resourceinformation infor- anddisplay that in appendix9. linesofPerl inthe illustrated asimplemented results, the returned canbeparsedandwilldisplayreceived, data that defi WSDL(appendix8). ned inthe hasbeen AuthorRequest way type data the sponds tothe parameters. appropriate AuthorRequest Itinvokes method the heavy lifting. dix 7,doesthe URL. component ofthe Breeding” asspecifi ed inthe appendix 6, array named into anassociative them commandlineandputs onthe to parseparameters common.pl ry AWS tosearch fi byauthor. Inthis gure, avariable— service. the comprise ings that andbind- messages, methods, types, data client aboutthe work the ofinforming itdoallthe andlets service the tothe points WSDL,soitsimply response.ceive Perl::Lite the supports usingSOAP,to begin request whichwillissuethe andre- aWebissues anHTMLheaderandbegins page. available, subroutines on aserver. Oneofthe GoogleWeb the describes API canbedisplayedle that —is set up to pass the value of the query. The value ofthe —is setuptopassthe Just like Google Web Amazon,inorder to usethe API, how onecandraw This simpleexampleillustrates hasbeeninvoked service andaresponseOnce is the Perl inthe scriptThe AuthorRequest corre- method script, shown inappen- ofthe The nextportion to clientwillsendaquery Appendix 6shows how the up things codesets shows how the The nextsection fi code the le (seeappendix3)alsocontains $fi elds{‘Author’} AmazonWebService.wsdl defi WSDLandpassesonthe ned inthe will take the value “Marshall willtakethe Author=Marshall Breeding fi elds . In the examplein . Inthe fi defile that nes mashup. &pagetop diglib- $que- ,

Library Technology Reports www.techsource.ala.org May—June 2006 21 When invoked, the script creates a Web page such as page the a Web creates script When invoked, The same results can be accomplished without structures known to exist in the API have been hard cod- structuresbeen hard in the to exist known API have similaritiesed into the many there are yet module, to the examples. Amazon search the Again, in appendix 11. one shown this demonstrates programmatically a user can service access a remote how service, obtainusing a Web content that from service, and thedisplay content in the the way user desires. module. Instead, thethe Perl user GoogleSearch.pm link it to the and directly use SOAP::Lite simply would The alternateGoogleSearch.wsdl. the of version is script 12. in appendix shown GoogleSearch require “diglib-common.pl”; require &pagetop; ServiceprintWeb “

Amazon Example

\n”; token # Amazon developer’s xxxxx’; here token Amazon developer put your $dev_token=’xxxxx my le #Location of the Amazon WSDL fi $amazon_wdsl = “http://soap.amazon.com/schemas2/AmazonWebServices.wsdl”;my use strict; use SOAP::Lite; $querymy = “Marshall Breeding”; #Constructinstance a new SOAP::Lite = SOAP::Lite->service(“$amazon_wdsl”); $search my Service# Execute Amazon Web -> $results = $search my AuthorSearchRequest(SOAP::Data->name(“AuthorSearchRequest”) ->type(“AuthorRequest”) ->value(\SOAP::Data->value( => $query), SOAP::Data->name(“author” => “1”), SOAP::Data->name(“page” => “books”), SOAP::Data->name(“mode” SOAP::Data->name(“type” => “lite”), => $dev_token) SOAP::Data->name(“devtag” )) ); print “

Items on Amazon by Marshall Breeding

\n”; results # Display (@{$results->{Details}}){ $result my foreach #print each entry of the set result print “

\n”; $auth my { (@{$result->{Authors}}) foreach print $auth,”. “; } ActiveState module the offers Perl , which implements a SOAP interface, which implements to the a SOAP methods .pm in the API. Appendix 10 is based on the Google available ActiveState The GoogleSearch module. GoogleSearch.pm .pm does not use the WSDL; rather the methods and data Appendix 3: SOAP Interface Example WSDL File Describing Google Web API Google Web WSDL File Describing http://api.google.com/GoogleSearch.wsdl Google Web API Google Web www.google.com/apis/index.html 22 Library Technology Reports www.techsource.ala.org May—June 2006 Script UtilizedforClienttoSendQuery AWS toSearchbyAuthor Appendix 6: Code That“Callsin”SubroutineforHTMLHeaderandBeginningofWeb Page Appendix 5: AWS Web ServiceExample Appendix 4: my $search =SOAP::Lite->service(“$amazon_wdsl”); anewSOAP::Lite instance #Construct =$fimy $query elds{‘Author’}; use SOAP::Lite; use strict; my $amazon_wdsl=“http://soap.amazon.com/schemas2/AmazonWebServices.wsdl”; Example\n”; “

AmazonWebprint Service &pagetop; require “diglib-common.pl”; &pagebottom; } “

\n”; print >0); onAmazon:“,$result->{OurPrice},”\n” if(length($result->{OurPrice}) “\nPrice print “\Publisher:“,$result->{Publisher},”\n” print >0); if(length($result->{Publisher}) >0); “”if(length($result->{Url}) print “$result->{ProductName}”; print “{Url},”\”>” print >0); if(length($result->{Url}) Library Technology Reports www.techsource.ala.org May—June 2006 23 ned in WSDL in ned print “

Items on Amazon by Marshall Breeding

\n”; results # Display (@{$results->{Details}}){ $result my foreach #print each entry of the set result print “

\n”; $auth my { (@{$result->{Authors}}) foreach print $auth,”. “; } if (length($result->{Url}) > 0); print “{Url},”\”>” print “$result->{ProductName}”; print “” if (length($result->{Url}) > 0); if (length($result->{Publisher}) > 0); print “\Publisher: “,$result->{Publisher},”\n” print “\nPrice if (length($result->{OurPrice}) on Amazon: “,$result->{OurPrice},”\n” > 0); print “

\n”; } &pagebottom; type=”xsd:string”/> # Execute Amazon # Execute Amazon Web -> $results = $search my AuthorSearchRequest(SOAP::Data->name(“AuthorSearchRequest”) ->type(“AuthorRequest”) ->value(\SOAP::Data->value( => $query), SOAP::Data->name(“author” => “1”), SOAP::Data->name(“page” => “books”), SOAP::Data->name(“mode” SOAP::Data->name(“type” => “lite”), => $dev_token) SOAP::Data->name(“devtag” )) ); Appendix 9: Display Results Appendix 8: Script Corresponds to AuthorRequest Data Type AuthorRequest Method in Perl (in WSDL) Appendix 7: Appendix Defi Invokes AuthorRequest, Script That 24 Library Technology Reports www.techsource.ala.org May—June 2006 Script BasedonActiveStateGoogleSearch.pmModule Appendix 10: &pagebottom; #endsHTMLpage&pagebottom; } “$entry->{snippet}

\n”; print “{URL}\”>$entry->{title}

\n”; print 0\”>$i. \n“; “{‘resultElements’}}) { foreach my $entry “

Thesearchprint was: $return->{‘searchQuery’}

\n”; “

Thenumber $return->{‘estimatedTotalResultsCount’}

\n”; print ofResults: #$resultdata->{‘GoogleSearchResults’}; #my $resultdata; my $i=0; )->result(); =>‘’, restrict =>10, maxResults =>0, start =>$search, query $return =$google->doGoogleSearch( my $search =$fi elds{‘query’}; # exampleofasearch didyou mean$return?

\n”; of$test

Instead print $return =$google->doSpellingSuggestion($test)->result(); my =‘marshalbreding’; $test API # exampleofusingspellingsuggestion my $return; my $google =newGoogleSearch(); my $key =‘xxxxxputyour Googlekey here xxxxxx’; for googlekey.txt ofGoogleSearchService.pm location # orinthe # ifkey isnotprovided, looksin$ENV{HOME}, GoogleSearchService use GoogleSearch; “

GoogleSearchprint Example

\n”; &pagetop(“Google Search HTMLpage Example”);#begins require (“interface.pl”); Library Technology Reports www.techsource.ala.org May—June 2006 25 Appendix 11: Appendix Client Google Search by the Embedded Displayed Page Web 26 Library Technology Reports www.techsource.ala.org May—June 2006 SOAP::Lite ClientAlternateScriptThatYields Web PageShowninAppendix11 Appendix 12: &pagebottom; } “

\n”; print “

”,$summary,”\n”; print =$result->{snippet}; $summary “{URL},”\”>”,$result->{title},”.”; print 0\”>$i.\n“; “{resultElements}}) my $i=0; “About print results.\n”; $results->{‘estimatedTotalResultsCount’} my =$googleSearch $results ->doGoogleSearch($key, “latin1”); $q,0,10,“false”,“”,“latin1”, didyou of$check mean$suggestion?

\n”; “

Instead print my =$googleSearch->doSpellingSuggestion($key, $suggestion $check); my $check=‘marshalbreding’; API # exampleofusingspellingsuggestion my $googleSearch =SOAP::Lite ->service(“http://api.google.com/GoogleSearch.wsdl”); my $q=”MarshallBreeding”; my $key =‘xxxxxputyour Googlekey here xxxxxx’; “

GoogleSearchprint Example

\n”; &pagetop(“Google Search HTMLpage Example”);#begins use SOAP::Lite; require (“interface.pl”);