1 grid web services and gateway ptliu laboratory for community grids marlon pierce, choonhan youn,...

50
1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics Indiana University, Bloomington IN 47404 http://grids.ucs.indiana.edu/ptliupages/publications/presentation s/ggf4feb02 [email protected] Part of GGF4 Tutorial Toronto February 17 2002 Grid Programming with Web Services, Software Components and Portal Development Tools

Upload: harold-dalton

Post on 13-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

1

Grid Web Services and Gateway

PTLIU Laboratory for Community GridsMarlon Pierce, Choonhan Youn, Geoffrey Fox,

Computer Science, Informatics, Physics

Indiana University, Bloomington IN 47404http://grids.ucs.indiana.edu/ptliupages/publications/presentations/ggf4feb02

[email protected]

Part of GGF4 Tutorial Toronto February 17 2002 Grid Programming with Web Services, Software Components and

Portal Development Tools

Page 2: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

2

Web service parts

• WSDL: describes service

• SOAP: protocol for remote procedure calls between client and server

• UDDI: Service registry.– White pages, yellow pages, and green

pages(?)

Page 3: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

3

                

 

SOAP Client

Connect and UseService

Discover Service from Registry

ServiceRegistryServer

Register Service

SOAPServer

UDDIRepositoryof WSDL Interfaces

Page 4: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

4

Tutorial Overview

• We’ll use batch script generation as our example web service. – This is an actual service developed by SDSC

(Stephen Mock) and IU (Choonhan Youn and Marlon Pierce).

• Basic steps:– Develop SOAP service.– Write WSDL service interface.– Put service in UDDI.

Page 5: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

5

Sample Web Service

• Generating batch scripts from user requests is a common task implemented by a several portals (including Gateway and HotPage). Stop reinventing this!

• Basics of the service:– An XML document using a DTD from SDSC is

created by the client and sent to the server.– The server takes this input, generates a script

for the requesting queuing system (PBS, GRD,…) and returns this to the client.

Page 6: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

6

Developing SOAP Services

A Java-centric look at deploying services and developing clients.

Page 7: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

7

SOAP Basics

• SOAP is a W3C standard for describing remote procedure calls in XML.– See http://www.w3c.org/TR/SOAP

• SOAP language bindings exist for Java, Python, Perl, ….– For Java, we use Apache SOAP 2.2 (being

deprecated in favor of Apache Axis).– Java Classes correspond to SOAP tags. – Clients and services communicate with SOAP over

HTTP behind the scenes.

• You can always roll your own SOAP messaging.

Page 8: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

8

Developing a Service and Setting Up a SOAP Server

• Nothing special required to develop a particular service– It just needs to be a Java class.

• You need a Tomcat or similar server for handling servlets.

• Get the SOAP war file from Apache and drop into the webapps directory.– See http://xml.apache.org/soap/ for

downloads and instructions

Page 9: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

9

Batch Script Generation Service

• We have a class called BatchScriptService.java.

• This has one public method,public String BatchGen(String xmlfile);

• For Gateway, we put this into the package WebFlowSoap.

• This is compiled and put in the Tomcat server’s classpath.

Page 10: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

10

Deploying the Service

• Now make your service available from your SOAP server (Tomcat+SOAP war file).

• Write a deployment descriptor for the particular service (like batch script generation).

Page 11: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

11

Example Deployment Descriptor for Batch Script Generator

<isd:service xmlns:isd="http://xml.apache.org/xml- soap/deployment" id="urn:BatchScriptService"

checkMustUnderstands="false"> <isd:provider type="java" scope="Application" methods="BatchGen"> <isd:java class="WebFlowSoap.BatchScriptService“ static="false"/> </isd:provider></isd:service>

Page 12: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

12

Looking at the Descriptor

• Note this is specific to Apache SOAP.• The Service ID is the name (URN) of your

service (BatchScriptService). checkMustUnderstands corresponds to the “MustUnderstand” element of the SOAP header.

• Provider is the language of the service. Scope corresponds to JSP scope variables. Methods attribute is the method name.

• The class attribute of the java tag points to the compiled BatchScriptService.class file in the classpath. The static attribute is true if the class uses Java static methods.

Page 13: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

13

Apache SOAP’s administration page, showing a list of deployed services.

Page 14: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

14

Follow the “Deploy” link and you can fill out forms to generate a Deployment Descriptor.

Page 15: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

15

HTML display of the Batch Script Generator’s Deployment Descriptor

Page 16: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

16

SOAP Clients

• You can write SOAP clients to directly interact with deployed SOAP services– SOAP-RPC over HTTP

• Steps for writing a Java client:– Create a Call object and connect to the server.

Specify the name (URN) of the service you want.– Create a Parameters object and pass the parameters

required by the method.– Use Call object’s invoke() method for invoking the

remote service.– Get the returned values from the method.

Page 17: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

17

Example: Creating the Call//Import Apache SOAP packagesimport org.apache.soap.*;import org.apache.soap.rpc.*;//Do other stuff (omitted)// Build the call. Call call = new Call (); call.setTargetObjectURI ("urn:BatchScriptService"); call.setMethodName ("BatchGen"); call.setEncodingStyleURI(encodingStyleURI); Vector params = new Vector (); params.addElement (new

Parameter("xmlFile",String.class,xmlFile,null)); call.setParams (params);

Page 18: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

18

Example: Invoke the remote method

//The url object below points to your Tomcat server’s rpc router Response resp = call.invoke (url,""); // Check the response. if (resp.generatedFault ()) { Fault fault = resp.getFault (); System.out.println ("Ouch, the call failed: "); System.out.println (" Fault Code = " + fault.getFaultCode ()); System.out.println (" Fault String = " + fault.getFaultString ()); } else { Parameter result = resp.getReturnValue (); System.out.println (result.getValue()); }

Page 19: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

19

Next Steps

• Limitations of the SOAP client– You have to know where the server is and the

services it provides (UDDI)– You have to know the service’s name, its

methods, and the methods’ interfaces (WSDL).

• It would be nice to have wrappers for generating the SOAP client code for a particular sevice.

Page 20: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

20

Using WSDL

An overview of the Web Services Description Language

Page 21: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

21

WSDL Overview

• WSDL is the W3C’s standard for describing method interfaces in XML.– See http://www.w3c.org/TR/wsdl.html

• It is equivalent to CORBA’s Interface Definition Language (IDL), only in XML.

Page 22: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

22

What WSDL Describes

• The name of the service (maps to a Java class).

• The service’s method names, arguments, and return types.

• WSDL is extended for specific carriers – For us, invoke using SOAP over HTTP– Other bindings can be used (HTTP

POST/GET, for examples).– Other carrier extensions are possible.

Page 23: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

23

Parts of a WSDL Document

• The total WSDL interface is composed of several decoupled but linked parts:– Messages define the requests and responses.– Port Types are templates for particular services and

specify input and output operations.– Bindings define how specific port types are

implemented (i.e., with SOAP RPC).– Ports are concrete implementations of Port Types.– Services are collections of one or more ports.

Page 24: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

24

WSDL Definitions

• The <definitions> tag starts the document.– All WSDL name attributes (such as the one in

definitions) are used for referring to this section of the document.

• Schema namespace definitions follow the definition. – You need to specify a namespace for your

WSDL

Page 25: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

25

WSDL Definitions and Namespaces

<?xml version="1.0" encoding="UTF-8" ?> <definitions name="BatchScriptService" targetNamespace="http://yourserver/BatchScriptService"

xmlns="http://schemas.xmlsoap.org/wsdl/"xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"

xmlns:tns="http://yourserver/BatchScriptService" xmlns:xsd="http://www.w3.org/1999/XMLSchema">

Page 26: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

26

WSDL Messages

• Message tags describe the communications between client and server.

• For the batch script service, we pass the XML description of the job as a string and get back the script as a string.

• In general, any XML primitive or complex types can be used in messages.– We could improve our service by defining a

BatchScript complex type.

Page 27: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

27

WSDL Message Example

<message name="submitRequest"> <part name="xmljob" type="xsd:string"/></message><message name="submitResponse"> <part name="response" type="xsd:string"/></message>

Page 28: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

28

WSDL Port Types

• Next, we define how the messages are organized.

• A port type corresponds to a Java class, so if we compile this WSDL to make client stubs, we will generate a BatchScriptServiceBinding.java class.

• Input and output tags link the port to the previously defined messages.

Page 29: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

29

WSDL Port Types

<portType name="BatchScriptServicePortType"> <operation name="batchGen"> <output message="tns:submitResponse"

name="submitResponse"/> <input message="tns:submitRequest"

name="submitRequest"/> </operation> </portType>

Page 30: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

30

WSDL Bindings

• Next, we define bindings for our port types (note binding’s “type” attribute points back to the portType tag by name).

• This is where WSDL gets extended for particular transport mechanisms. – Note the <soap:operation> and other tags.– These would be replaced by http or mime

bindings, for example, if we were using those.

Page 31: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

31

WSDL Bindings

<binding name="BatchBinding" type="tns:BatchScriptServicePortType"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="batchGen"> <soap:operation soapAction=""/> <input> <soap:body use="encoded" namespace="urn:BatchScriptService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </input> <output> <soap:body use="encoded" namespace="urn:BatchScriptService“ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </output> </operation> </binding>

Page 32: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

32

WSDL Ports and Services

• Ports are concrete implementations of Port Types and point back to a particular Binding (by name).

• They also point to the specific location of a server that implements the service.

• A service is a collection of one or more ports.

Page 33: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

33

WSDL Services<service name="BatchScriptService"> <documentation>BS stands for Batch Script </documentation> <port binding="BatchBinding”

name="BatchPort"> <soap:address location=

"http://yourserver/soap/servlet/rpcrouter/"/> </port> </service>

Page 34: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

34

Using WSDL in Java

• We use IBM’s Web Service Toolkit (WSTK).– Can examine a Java service class and generate the

WSDL and Deployment Descriptor automatically.– For a given WSDL file, it can generate a Java client

class that implements the WSDL methods as RPC SOAP calls.

– So you can “compile” your WSDL into a client side stub. You then write a client to use this remote object.

– Entirely like CORBA+IDL, but entirely optional. Basic SOAP clients may be preferable for dynamically discovering and invoking methods through WSDL.

Page 35: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

35

Setting Up Your UDDI Registry

How to add your service to a registry and how to develop clients that can

search the registry.

Page 36: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

36

What can you get from UDDI?

• Name of “business” and its services• Location of SOAP server(s) that provide

these services• Locations of WSDL files so you know how

to use service• Refined descriptions:

– Business descriptions– Service canonical categories – Service identifiers

Page 37: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

37

Setting Up Your UDDI

• We tried SOAP UDDI, IBM UDDI Preview• SOAP UDDI is open source, free, but under

development – Can’t search by UDDI search types

• Case sensitive, wild card searches don’t work– UDDI Categories are not supported– Removing entries from UDDI has bugs

• IBM’s product is commercial, uses WebSphere, DB2.– Early experience indicates it supports more features.

• We ran both on Windows 2000 PCs.

Page 38: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

38

Example: IBM UDDI

• The following are some screen shots of our UDDI test registry.

• Following shot is the entry page

Page 39: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

39

Page 40: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

40

On Next Slide

• This lists all the business entries in the UDDI (SDSC and Gateway).

• Also lists the services that Gateway provides (including the batch script generation service).

• In general, the UDDI contains Business names, Service Names, Service Types

• You can search UDDI based on any of these categories.

• Search can be done through web interface by human, or through by any client program using standard UDDI API.

Page 41: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

41

Page 42: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

42

On Previous Page

• “Service Name” is the list of all names corresponding to the WSDL files for specific services.

• Example: BatchScriptService.

• The listed service names correspond to the <service name> tag from WSDL.

• This tells you the location of the SOAP– http://host:8080/soap/servlet/rpcrouter

Page 43: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

43

On Next Page

• This is the display that you get if you click on the BatchScriptService link under Gateway’s Service Name listing.

• The main thing here is that it tells you where the SOAP server is located.

Page 44: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

44

Page 45: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

45

On Next Slide

• This is what you get if you click the bss-interface link from the main page (slide 41 here).

• The main thing is that this page tells you where to find the WSDL file for the batch script service.

Page 46: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

46

Page 47: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

47

Publishing Your Service

• Note UDDI Registry is a general business registry, so services may be human-to-human.

• Add your business (name, description, contact person, locations).

• Add services: names, how to access (may be web, but may be FAX, phone)– For us, location of SOAP server that has deployed the

service.• Add the service type. You put the WSDL file

location here.• This can be done either through the web

interface or by a program using the UDDI API.

Page 48: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

48

Example Service

• Indiana University and San Diego SC want to offer a batch script generation service. – Agree to the WSDL interface for invoking RPC– Publish in UDDI Registry

• Two business entities: Gateway and SDSC• One service (batch script service)• Two locations for SOAP servers.

• Note WSDLs do not have to be identical if clients are dynamic

Page 49: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

49

Using API to Publish

• We are using UDDI4J from IBM (implementation of Java bindings).

• Most important class: UDDIProxy class: represents UDDI server and its functions.

• Important methods:– Login to remote server– Write and update business info to server

• UDDIProxy class methods are invoked on server with SOAP.

Page 50: 1 Grid Web Services and Gateway PTLIU Laboratory for Community Grids Marlon Pierce, Choonhan Youn, Geoffrey Fox, Computer Science, Informatics, Physics

50

Writing UDDI Clients

• I want to search the UDDI for a batch script generator. I want to be able to search by– Name of “business” (like SDSC)– Name of service (the batch script service)– Specific queuing systems supported (LSF)

• See FindData.java for examples.