Download presentation
Presentation is loading. Please wait.
Published byBarnaby O’Neal’ Modified over 8 years ago
1
November, 2006 Developing Service using GT4 Writing Your First Stateful Web Service in 5 Simple Steps Adam Belloum
2
November, 2006 Outline What is OGSA, WSRF, GT4? The MathService example 5 steps to implement GT4 MathService: Step1: define the Interface in the WSDL Step2: implement the MathService in java Step3: configure the deployment ( WSDD & JNDI ) Step4: create the deployement File Step5: The client application
3
November, 2006 Preparation: download GT4, and ANT Make sure you use bash shell not a tcshell Just Type $ bash Download the WS-core service of GT4 www.globus.org/toolkit/downloads/4.0.4/#wscore_bin/ Untar the compressed file: just type $ tar zxvf ws-core-4.0.4-bin.tar.gz Download the Ant version 7 http://ant.apache.org/bindownload.cgi/ $ tar zxvf apache-ant-1.7.0-bin.tar.gz NOTE:
4
November, 2006 Preparation: setting up your environment Define & set the environment variable ANT_HOME $ export ANT_HOME=$HOME/ / GLOBUS_LOCATION $ export GLOBUS_LOCATION=$HOME/ / JAVA_HOME $ export JAVA_HOME=/usr/java/ PATH: $ export PATH=$JAVA_HOME/bin: \ $ANT_HOME/bin: \ $GLOBUS_LOCATION/bin:$PATH NOTE: we use $HOME because installed both ANT and WS-CORE in you home directory
5
November, 2006 Preparation: test if it works Start the container: $ globus-start-container –nosec Watch your screen carefully spot any Error message Stop the container: $ globus-stop-container NOTE: globus-stop-container seem to require grid credential, for now just stop the container +C or the unix command kill
6
November, 2006 Preparation: Finally download the tutorial This is a very important step if you don’t want to re-write everything from scratch http://gdp.globus.org/gt4-tutorial/ $ tar zxvf progtutorial- examples_0.2.1.tar.gz
7
November, 2006 You are ready to start your first experience with The Grid Enjoy & Good luck
8
November, 2006 Introduction: OGSA, WSRF, and GT4 Open Grid Services Architecture (OGSA), developed by The Global Grid Forum, aims to define a common, standard, and open architecture for grid- based applications OGSA Stateful Web service WSRF Notification WSRF fault WSRF Resource Properties WSRF Life WSRF requires extends specifies Web Services Resource Framework, a specification developed by OASIS. WSRF specifies how we can make our Web Services stateful, along with adding a lot of other cool features
9
November, 2006 Introduction: How does this relate to GT4? GT4, includes quite a few high-level services that can be used to build Grid applications These services, meet most of the abstract requirements set forth in OGSA GT4 includes a complete implementation of the WSRF specification. GT4 isn't the only WSRF implementation. Another complete implementation of the WSRF specification is WSRF.NET. Service Implementation (java) Service Implementation (java) Other packages (WSRF.NET, …) Globus Toolkit 4 High-level Services Adequate for Grid Applications High-level Services Adequate for Grid Applications meet requirements of Implemented on top of Implements OGSA Stateful Web service WSRF Notification WSRF fault WSRF Resource Properties WSRF Life WSRF requires extends specifies
10
November, 2006 Introduction: The mandatory layered diagram Applications OGSA Web service WSRF Grid Application based On the high-level service defined by OGSA (not implemented form scratch ) Standards in the work (ggf) -VO management -Security -Resource Management -Data services Etc. GT4 include many of the services required by OGSA Standardized (OASIS) and implemented GT4 Standardized (W3C) and implemented (e.g. Apache axis)
11
November, 2006 Tutorial starts:The first web service MathService will have the following resource properties (RPs for short): o Value (integer) o Last operation performed (string) public interface Math { public void add(int a); public void subtract(int a); public int getValueRP(); } The first web service is an extremely simple Math Web Service, which we'll refer to as MathService. It will allow users to perform the following operations: o Addition o Subtraction
12
November, 2006 The MathService web service Client MathService Void add(int a) Void sub(int a) The Client interacts with the stateless Web service GT4 suplies a resource home called ServiceResourceHome When asked for a resource, this special type of resource home always returns service object GT4 ServiceResourceHome STATEFUL MathResource Int value String last Op Add() & substract() operation on the resource propertiesContained in the resource STATELESS
13
November, 2006 Step 1: Define the Interface in WSDL WSRF and GT4-specific features of WSDL Resource properties The WSDL Preprocessor No bindings: Bindings are an essential part of a normal WSDL file. However, we don't have to add them, they are generated automatically by a GT4 tool that is called when we build the service Namespace mappings WSDL is that it's language-neutral. Because we need to refer to the interface defined in WSDL from some specific language we need to: o map WSDL namespaces to specific language (Java packages) o $EXAMPLES_DIR/namespace2package.properties
14
November, 2006 Step 1: Define the Interface in WSDL <definitions name="MathService" location="../../wsrf/properties/WS-ResourceProperties.wsdl" /> … … <portType name="MathPortType" wsdlpp:extends="wsrpw:GetResourceProperty“ wsrp:ResourceProperties="tns:MathResourceProperties"> > … $EXAMPLES_DIR/schema/examples/MathService_instance/Math.wsdl … … … …
15
November, 2006 Step 2: Implementing the Service The QNames interface o QNames includes a namespace and a local name. o For example, the QName of the Value RP is: {http://www.globus.org/namespaces/examples/co re/MathService_instance}Value $EXAMPLES_DIR/org/globus/examples/services/co re/first/impl/MathQNames.java The service implementation $EXAMPLE_DIR/org/globus/examples/services/cor e/first/impl/MathService.java
16
November, 2006 Step 2: Implementing the Service package org.globus.examples.services.core.first.impl; import java.rmi.RemoteException; Import public class MathService implements Resource, ResourceProperties { /* Resource Property set */ private ResourcePropertySet propSet; /* Constructor. Initializes RPs */ public MathService() throws RemoteException {…} /* Get/Setters for the RPs */ … /* Remotely-accessible operations */ … /* Required by interface ResourceProperties */ public ResourcePropertySet getResourcePropertySet() { return this.propSet; } } public MathService() throws RemoteException { /* Create RP set */ this.propSet = new SimpleResourcePropertySet( MathQNames.RESOURCE_PROPERTIES); /* Initialize the RP's */ try { ResourceProperty valueRP = new ReflectionResourceProperty( MathQNames.RP_VALUE, "Value", this); this.propSet.add(valueRP); setValue(0); … } catch (Exception e) { throw new RuntimeException(e.getMessage()); } public AddResponse add(int a) throws RemoteException { value += a; lastOp = "ADDITION"; return new AddResponse(); } public int getValue() { return value; }
17
November, 2006 Step 3: Configuring the deployment in WSDD (and JNDI) The WSDD deployment descriptor The file that tells the Web Services container how it should publish our web service deployment descriptor is written in WSDD format (Web Service Deployment Descriptor) The JNDI deployment file specifies: what resource home our service has to use to get a hold of resources. parameters related to how the resource home manages those resources. Here we use the standard GT4 ServiceResourceHome which always returns service object <deployment name="defaultServerConfig" xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <service name="examples/core/first/MathService" provider="Handler" use="literal" style="document"> <parameter name="className“ value="org.globus…..core.first.impl.MathService"/> share/schema/examples/…/Math_service.wsdl factory org.globus.wsrf.jndi.BeanFactory
18
November, 2006 Step 4: Create & deploy a GAR file Service Interface (WSDL) Service Implementation (java) Service Implementation (java) Service Implementation (java) Provided with the GT4 distribution Provided with GT4 tutorial Deployment Files WSDD & JNDI Deployment Files WSDD & JNDI Apache Ant Ant Build file build.xml GAR File GT4 build files GT4 build files GT4 build files./globus-build-service.sh \ -d org/globus/examples/services/core/first/ \ -s schema/examples/MathService_instance/Math.wsdl globus-deploy-gar $EXAMPLES_DIR/org_globus_examples_services_core_first.gar globus-undeploy-gar org_globus_examples_services_core_first NOTE: deployment command must be run with a user that has write permission in $GLOBUS_LOCATION
19
November, 2006 Step 5: Simple Client … public static void main(String[] args) { MathServiceAddressingLocator locator = new MathServiceAddressingLocator(); try { String serviceURI=args[0]; //step: 1 EndpointReferenceType endpoint = new EndpointReferenceType(); endpoint.setAddress(new Address(serviceURI)); //step: 2 MathPortType math = locator.getMathPortTypePort(endpoint); //step: 3 math.add(10); System.out.println("Current value:" + math.getValue(new GetValueRP())); } catch (Exception e) { e.printStackTrace(); } create an EndpointReferenceType object representing the endpoint reference of this service. Obtain a reference to the service'sportType. This is done with a stub class called MathServiceAddressingLocator that, given the service's EPR, returns a MathPortType object that will allow to contact the Math portType.. invoke the remote add operation, we simply have to use the add method in the MathPortType object..
20
November, 2006 Step 5: compile and run the Simple Client 1.Set the environment for the client $ source \ $GLOBUS_LOCATION/etc/globus-devel-env.sh 2.Compile the simple client $ javac –classpath \./build/stubs/classes/:$CLASSPATH \ org/globus/examples/clients/MathService_instance/Client.java 3.run the simple client $ java \ -classpath \./build/stubs/classes/:$CLASSPATH \ org.globus.examples.clients.MathService_instance.Client \ http://127.0.0.1:8080/wsrf/services/examples/core/first/MathService
21
November, 2006 Test your knowledge 1.What is OGSA, WSRF, GT4 ? 2.How does GT4 related to OGSA and WSRF? 3.which standardization body are involved? Who is doing what ? 4.What are the WSRF specific part to be added to the a standard WSDL 5.what is the role of the mapping 6.What is the role of the Qname 7.what is the Role of WSDD and JNDI 8.what are the steps to do to be able to use the service 9.What will happened if multiple clients try to use the first implementation ? 10.What are the limits of this first implementation ?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.