web services (tying it all together) and introduction to grid services concepts these slides are...
TRANSCRIPT
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/
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.
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.
2. Find
3. Bind
1. Publish
Service-Oriented Architecture
Service requester
Service registry
Service provider
Web Services “Stack”
+ XML
Calling a Web Service
From http://www.globus.org
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
URIs also include email addresses, i.e.
mailto:[email protected]
and
Uniform Resource Names (URNs) which are globally unique and persistent. UDDI uses URNs.
Hosting Environments for Web Services
• Microsoft .NET
• IBM Websphere
• Apache Axis - we are using this for the Web Services exercise
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.
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.
Web Service Application
Call client stubSOAP
requestRequest service
Result returnedSOAP
responseClient receives result
Web Service Description
• Need a way of formally describing a service, what is does, how it is accessed, etc.
• An Interface Description language (IDL)
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.
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
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.
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.
• 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.
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).
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
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.
Web Services Exercise
This assignment uses:
– Java 2 platform standard edition– Apache Jakarta Tomcat Java servlet container– Apache Axis tools
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.
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.
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.
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
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
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/
Step 3 Compile new source files
Compile source files generated by step 2 with:
javac -classpath $AXISCLASSPATH \localhost/axis/yourusername/MyMath_jws/*.java
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)); }}
Step 5 Compile Client code
Compile the client source file with:
javac -classpath $AXISCLASSPATH:. MyMathClient.java
Step 6 Execute Web Service program
java -classpath $AXISCLASSPATH MyMathClient 4
The square of 4 is 16
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.
Extra Credit (not on assignment page)
• For extra credit, create a second web service and demonstrate a client using two web services.
Grid Services Concepts
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.
Grid Services
• Standard provides for interoperability of independently developed services
• Grid services based on extensions of Web Services
The Globus Grid Forum (GGF) standard currently divided into:
Open Grid Services Architecture (OGSA)
and
Open Grid Services Infrastructure (OGSI)
Open Grid Services Architecture(OGSA)
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
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
Based on http://www.globus.org
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.
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.
From http://www.globus.org
• 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.
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.
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.
Grid Services Factory
From http://www.globus.org
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.
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)
Next time
• More details on Grid Services and GT3
It is time to talk about projects.