Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Distributed Web Software • Presentation-based, e.g., dynamic web pages • Service-based – Web Services Importance of Web Services • Larry Page, on why Google introduced its search API: “Within a few years, there will be more programs (agents) accessing Google than people accessing Google.” Problems with PresentationBased Services • Server determines what to display and how to display it. • Combining services is difficult – Web page wrappers/scrapers Sample Web Apps • Travel Site – Access web services of all major airlines – List in sorted order the best prices for desired destination/time. • WebTop – Allows user to pull in context from various sources. Dynamic Web Pages Database A Database D Database B Database C Web Services Service D Service A Service B Service C Database A Database D Database B Database C Sample Web Service: The Google API • http://images.google.com/apis/ • Your Java/.Net program can call Google functions. • SOAP underneath the hood • Let’s try it… Google API Tutorial • • • • • Download at http://images.google.com/apis/ Extract files from zip into directory “Google” Register to get a key (same page). Open the readme file that was downloaded. Run the demo program from “Google” dir: java -cp googleapi.jar com.google.soap.search.GoogleAPIDemo <key> search Foo Where <key> is your registration key and Foo is the item you wish to search for. Google API Tutorial • Check out the Google API – Go to javadoc directory and click on index.html – API Reference page is “APIs_Reference.html” • Check out demo program – GoogleAPIDemo.java in main dir. – Run it. Google API Assignment • Write a class USFInward with a main program that lists the URLs (only) of five web pages that point to www.usfca.edu. • Instead of beginning from scratch, modify GoogleAPIDemo.java. Google Assignment Solution • SaveAs GoogleAPIDemo.java to USFInward.java. • Rename class in source file. • Replace the package statement at top with: – import com.google.soap.search.*; • Modify code to perform requested actions. • javac -classpath googleapi.jar USFInward.java • Add “.” to classpath in execution line: java -cp .;googleapi.jar USFInward.java Google Solution Issues • Define a private static final int MAX=5 • Search string should be “linkto:www.usfca.edu” • Use GoogleSearchResult.getResults() to get array, then loop on each GoogleSearchResultElement calling getURL() Google Web Service: Under the Hood Java Client C# Client Java API C# API SOAP API Google DB Google Crawler Other Client Amazon Web Service • http://associates.amazon.com/exec/panama/ associates/ntg/browse/-/1067662/0863054474-4553435 UDDI Registries Writing Web Service Clients in Java WSDL – Web Service Description Language UDDI- Registry of Web Services 1. Fine Web Service WSDL document in UDDI. 2. Generate Java stubs to access service: WSDL wscompile Java stubs 3. Write Java client that accesses service through stubs. Creating a Web Service • Similar to RMI, define a “Remote” interface – public interface MathService extends Remote { int add(int x, int y) throws RemoteException; //… } • Implement the interface – public class MathServiceImpl implements MathService { public int add( int x, int y) throws RemoteException; { return x+y; } Creating a Web Service (cont.) • Use wsdeploy to create “ties” and WSDL file: MathService.java MathServiceImpl.java wsdeploy WSDL Java ties • Package and Deploy– Build Web App Resource (WAR) file • web.xml descriptor file