web services (tying it all together) and introduction to grid services concepts these slides are...

52
Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson, http://sol.cs.wcu.edu/~abw/CS 493F04/

Upload: letitia-stafford

Post on 25-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Web Services(tying it all together)

and Introduction to Grid Services Concepts

These slides are adapted from course material developed by Barry Wilkinson, http://sol.cs.wcu.edu/~abw/CS493F04/

Page 2: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Web Services

• Software components designed to provide specific operations (“services”) accessible using standard Internet technology.

• Similar to RMI, CORBA, …– Client/server– Platform independent

• Usually through SOAP (simple Object Access Protocol) messages carrying XML documents, and a HTTP transport protocol.

Page 3: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Service-Oriented ArchitectureSteps:

• Services “published” in a Service registry.

• Service requestor asks Service Registry to locate service.

• Service requestor “binds” with service provider to invoke service.

Page 4: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

2. Find

3. Bind

1. Publish

Service-Oriented Architecture

Service requester

Service registry

Service provider

Page 5: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Web Services “Stack”

+ XML

Page 6: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Calling a Web Service

From http://www.globus.org

Page 7: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Address of a Web Service

• Uses URI’s (Uniform Resource Identifiers) - web naming mechanism.

• URLs are a subset of URI, and would typically be used, e.g.:

http://talon.csce.uark.edu/~aapon/myMath

Page 8: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

URIs also include email addresses, i.e.

mailto:[email protected]

and

Uniform Resource Names (URNs) which are globally unique and persistent. UDDI uses URNs.

Page 9: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Hosting Environments for Web Services

• Microsoft .NET

• IBM Websphere

• Apache Axis - we are using this for the Web Services exercise

Page 10: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Client-Service Implementation

• Just as in Java RMI, client and server stubs are used to handle the networking details. – Java classes suitable for web services defined with WSDL.

• Client stub marshalls the request,

• Server stub receives a SOAP request from the client stub and converts it into a suitable form for the service -unmarshalling.

• Also converts the response from the service into a SOAP message for the client stub.

Page 11: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Steps

• Client calls client stub.

• SOAP request sent across network

• Server stub receives request and sends request to service

• Service send result to serve stub

• Server stub sends result across network to client stub.

• Client stub sends result to client.

Page 12: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Web Service Application

Call client stubSOAP

requestRequest service

Result returnedSOAP

responseClient receives result

Page 13: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Web Service Description

• Need a way of formally describing a service, what is does, how it is accessed, etc.

• An Interface Description language (IDL)

Page 14: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Web Service Definition Language (WSDL)

A W3C standard XML document that describes three fundamental properties of a service:

• What it is - operations (methods) it provides.

• How it is accessed - data format, protocols.

• Where it is located - protocol specific network address.

Page 15: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Parts of a WSDL Document

Parts of an WSDL document::• Root definitions - namespaces

• portType definitions - abstract definition of service

• Message definitions - parameters in method signature

• Type definitions - data types

• Binding definitions - to protocols I.e. SOAP over HTTP

• Service definitions - where service is, ports

Page 16: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Building a ServiceBackground for Web Services exercise

To build (deploy) a service one has to create:

• a WSDL document for the service

• the client stub

• the server stub

and test with a client.

Page 17: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Java Web Service (JWS)(The easy way to deploy a service)

• With JWS facility, service code with jws extension in the Axis-enabled web application is interpreted a web service.

• .jws file automatically compiled if necessary when service called.

• Simple and used in Web Services exercise but has limitations.

Page 18: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

• Could actually use the web service after deployment with JWS without using a WSDL file nor stubs!

• Just use the service URL which would have a .jws extension - need some code in client and service to make SOAP calls.

Page 19: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

WSDL from Code

• One can write the service code (as a class or interface) and then use tools to generate the WSDL document.

– Axis Java2WSDL program generates WSDL file (and its scheme).

Page 20: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

WSDL from Running Service

• Another Axis tool can generate the WSDL document.directly from a running deployed service.

• add ?wsdl onto service URL.

• Example of this in Web Services exercise

Page 21: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Stubs from WSDL

• If we have the WSDL document for the service, can use tools to generate client and server stubs:

– Axis WSDL2Java program generates stubs for use on client and server

– Example of this in Web Services exercise.

Page 22: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Web Services Exercise

This assignment uses:

– Java 2 platform standard edition– Apache Jakarta Tomcat Java servlet container– Apache Axis tools

Page 23: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Exercise Steps

• Write the Java code to implement the web service.

• Use Axis to generate all needed Java source files.• Compile the source files just generated.• Create client source and compile.• Execute client to access service.• Extend the functionality of the service.

Page 24: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Axis Java Web Service Facility

• Place a jws (rather than java) file in your web application directory structure and Axis will automatically find it, compile it, and deploy the methods.

Page 25: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Step 1 – Implement Service

Using Java write the code for the class that provides the web service. This code is:

public class MyMath { public int squared(int x) { return x * x; }}

Save that code as a .jws (Java Web Service) file, Math.jws.

Page 26: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Step 1 (continued)

Copy the .jws file to the axis directory:

cp MyMath.jws \

$CATALINA_HOME/webapps/axis/yourusername

Copying is needed so that the axis tools will be able to find the .jws file

Page 27: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Step 2 Generate WSDL files

Use the Axis tools to create four Java source files from MyMath.jws using the command:

java -classpath $AXISCLASSPATH \org.apache.axis.wsdl.WSDL2Java \http://localhost:8080/axis/MyMath.jws?wsdl

Page 28: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Step 2 (continued)Axis finds MyMath.jws file and creates

• Two source files each holding a Java interface, – MyMath.java and – MyMathService.java

• Two source files each holding a Java class, – MyMathServiceLocator.java– MyMathSoapBindingStub.java

These files are put in a new package inlocalhost/axis/yourusername/MyMath_jws/

which is in /home/yourusername/WebServices/

Page 29: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Step 3 Compile new source files

Compile source files generated by step 2 with:

javac -classpath $AXISCLASSPATH \localhost/axis/yourusername/MyMath_jws/*.java

Page 30: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Step 4: Write Client Source

import localhost.axis.yourusername.MyMath_jws.MyMathServiceLocator;import localhost.axis.yourusername.MyMath_jws.MyMathService;import localhost.axis.yourusername.MyMath_jws.MyMath;

public class MyMathClient { public static void main(String args[]) throws Exception { MyMathService service = new MyMathServiceLocator(); MyMath myMath = service.getMyMath(); int x = (new Integer(args[0])).intValue(); System.out.println("The square of " + args[0] + " is "

+ myMath.squared(x)); }}

Page 31: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Step 5 Compile Client code

Compile the client source file with:

javac -classpath $AXISCLASSPATH:. MyMathClient.java

Page 32: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Step 6 Execute Web Service program

java -classpath $AXISCLASSPATH MyMathClient 4

The square of 4 is 16

Page 33: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Step 7 Extend the Web Service

Add functionality to the MyMath web service:

• Add a method that returns whether a number is even.

Modify MyMath.jws file and repeat all previous steps to test the extended web service.

Page 34: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Extra Credit (not on assignment page)

• For extra credit, create a second web service and demonstrate a client using two web services.

Page 35: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Grid Services Concepts

Page 36: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Grid service

The Global Grid Forum (GGF) developed standard interfaces, behaviors, core semantics, etc. for grid applications based upon web services.

GGF introduced the term Grid Service as an extended web service that conforms to the GGF OGSI standard.

Page 37: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Grid Services

• Standard provides for interoperability of independently developed services

• Grid services based on extensions of Web Services

Page 38: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

The Globus Grid Forum (GGF) standard currently divided into:

Open Grid Services Architecture (OGSA)

and

Open Grid Services Infrastructure (OGSI)

Page 39: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Open Grid Services Architecture(OGSA)

Page 40: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

OGSA

• Defines standard mechanisms for creating, naming, and discovering Grid service instances.

• Addresses architectural issues relating to interoperable Grid services.

• Described in “The Physiology of the Grid” http://www.globus.org/research/papers/ogsa.pdf

Page 41: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

OGSI(Open Grid Services Infrastructure)

Based upon Grid Service specification and specifies way clients interact with a grid service (service invocation management data interface, security interface, ...).

Details:

http://www-unix.globus.org/toolkit/draft-ggf-ogsi-gridservice-33_2003-06-27.pdf

Page 42: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Based on http://www.globus.org

Page 43: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

The core elements of the Open Grid Services Architecture (shared)

This layer eliminated in most recent version of standard under development

The Grid 2: Blueprint for a new Computing Infrastructure, Ian Foster, Carl Kesselman and Steve Tuecker Editors, Morgan Kaufmann 2004 -- Chapter 17: “The Open Grid Service Architecture,” by Ian Foster, Carl Kesselman and Steve Tuecker.

Page 44: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Globus

Open source grid software toolkit.

Version 3 includes:

• A complete implementation of OGSI

• Additional Web service components, some built on top of OGSI.

We will use Globus 3.2 in Grid Services exercise.

Page 45: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

From http://www.globus.org

Page 46: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

• Grid services concept similar to Remote Procedure Call (RPC), Remote Method Invocation (RMI), only applied over HTTP

• In fact, Java implementations will use RMI underneath.

Page 47: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Differences between a web service and a grid service

Grid services can be:

• Stateful or Stateless

• Transient or Non-Transient.

A web services is usually thought of as non-transient and stateless.

Page 48: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Instances of Grid services

• Clients interact with instances of grid services.

• Apart from being the usual approach in an object oriented system, it enables clients to have access to different instances of a service and provides extended functionality to a web service. Allows for transient and private instances.

• Grid Services uses a Factory Service to create and manage service instances.

Page 49: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Grid Services Factory

From http://www.globus.org

Page 50: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Client - Service Interaction

• One-to-One -- a client has its own instance of a service. Most likely, instance destroyed with interaction finished.

• One-to-many -- instance of a services available to multiple clients. Information from service available to multiple clients.

Page 51: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Grid Service Implementation

• Can be accessed remotely

• Potentially stateful

• Implements one of more WSDL portTypes

• Grid Service Factories can be used to create instances of services with many portTypes

• Introspection of a service to return information (list of portTypes it implements)

Page 52: Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,

Next time

• More details on Grid Services and GT3

It is time to talk about projects.