18
Distributed Web Software Presentation-based, e.g., dynamic web pages Service-based – Web Services

Distributed Web Software Presentation-based, e.g., dynamic web pages Service-based – Web Services

  • View
    216

  • Download
    0

Embed Size (px)

Citation preview

Distributed Web Software

Presentation-based, e.g., dynamic web pages

Service-based – Web Services

Without Web Service Layer:Content and Presentation mixed

Database A Database B Database C Database D

ServletServletServletServlet

html htmlhtmlhtml

Web Services: Aggregators

Database A

Database B Database C

Database D

Service BService A

Service C

Service D

Aggregator Servlet

html

View How You Want

Database

Service

View How You Want, Examples

Show Google Scholar as a graph Various Bookstores using Amazon

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.”

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

Google DB

SOAP API

Java API C# API

Java Client C# Client Other Client

Google Crawler

Amazon Web Service

http://associates.amazon.com/exec/panama/associates/ntg/browse/-/1067662/086-3054474-4553435

UDDI Registries

Writing Web Service Clients in Java

WSDL – Web Service Description Language

UDDI- Registry of Web Services

WSDL wscompile Java stubs

1. Fine Web Service WSDL document in UDDI.

2. Generate Java stubs to access service:

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:

wsdeploy WSDL

Java ties

MathService.javaMathServiceImpl.java

• Package and Deploy– Build Web App Resource (WAR) file

• web.xml descriptor file