WebServicesDotNet3.5..

Download Report

Transcript WebServicesDotNet3.5..

Distributed Web Software


Presentation-based, e.g., dynamic web
pages
Service-based – Web Services
Without Web Service Layer:
Content and Presentation mixed
html
Servlet
Database A
html
html
html
Servlet
Servlet
Servlet
Database B
Database C
Database D
Web Services: Aggregators
html
Aggregator Servlet
Service D
Service A
Service B
Service C
Database A
Database D
Database B
Database C
View How You Want
Service
Database
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.GoogleAPIDem
o <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/086-3054474-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