Presentation is loading. Please wait.

Presentation is loading. Please wait.

Assignment 2 Modifying, Compiling, and Deploying a Simple Service Presenter Information goes Here.

Similar presentations


Presentation on theme: "Assignment 2 Modifying, Compiling, and Deploying a Simple Service Presenter Information goes Here."— Presentation transcript:

1 Assignment 2 Modifying, Compiling, and Deploying a Simple Service Presenter Information goes Here

2 Beyond Axis -> Globus Web Services The axis program from Assignment 1 was stateless, that is, the service did not remember previous operations. Globus Web Services now introduce the idea of state, that is, a service can remember what was previously done to the service.

3 An Interface For Our Service Supposing we were going to create a Java interface for our service, we would create: public class MathService { public void add( int num ); public void subtract( int num ); public int getValue(); }

4 Defining the Service in WSDL Instead of having a Java class and creating the WSDL as we did in Assignment 1, we are given the WSDL here: /home/username/ assignment2/schema/ examples/ MathService_instance/ Math.wsdl

5 Excerpts from the WSDL <definitions name="MathService“ targetNamespace="http://www.globus.org/namespaces /examples/core/MathService_instance“ – Defines that the service name is “MathService” and specifies the default name space. - Specifies that there is a method called ‘ add ’ which takes an ‘ int ’. Each response (i.e. ‘ addResponse ’) must also have an entry.

6 (Con’t) Excerpts from the WSDL - The fields from the service. That is, there is a field called ‘value’ and a field called ‘lastOp’ in the Java class. - Creates the response for the method invocation of ‘ add ’.

7 (Con’t) Excerpts from the WSDL <portType name="MathPortType"

8 Creating The Service From the ‘ assignment2 ’ directory, the source for the client is located in org/globus/examples/services/ core/first/impl/MathService.java

9 Important Sections of The Source private int value; private String lastOp; These fields provide state to the service. This method provides the ‘ add ’ method. public AddResponse add(int a) throws RemoteException { value += a; lastOp = "ADDITION"; return new AddResponse(); }

10 A Brief Mention of the Deployment Descriptor Another XML document is the deployment descriptor. (WSDD) This document provides the necessary details for the server. A few of the lines ‘just has to be there’. We will skip showing this file.

11 Finally! - Building The Service The Soyomotor tutorial provided a script file to build the service using Ant (Another Neat Tool). Steve McKinney, from ASU, created two scripts ( nameChanger.sh and build.sh ) to allow multiple people to run the same web service. Run the build: %./build.sh first

12 Deploying the GAR file As a security precaution, only the globus user can deploy web services. To allow multiple users to deploy services, we use sudo. Sudo allows one user to execute a command as another user.

13 Deployment (Con’t) From the command line: % sudo –u globus globus-deploy-gar \ org_globus_examples_services_core_username_first.gar The result should be ‘Deploy Successful’.

14 Starting the Container To be able to access our service, we must have a container that lists the service. To start the new container, the globus user runs the following command: % globus-start-container -nosec

15 Compiling The Client The client is provided at: The client contains several important parts, which will be explained next. /home/yourusername/Assignment2/org/globus/examples/clients/ MathService_instance/Client.java

16 Client Source Code – Explained! MathServiceAddressingLocator locator = new MathServiceAddressingLocator(); This code creates the locator for the MathService. EndpointReferenceType endpoint = new EndpointReferenceType(); endpoint.setAddress(new Address(serviceURI)); This code sets the location of the service. math = locator.getMathPortTypePort(endpoint); This code points the MathPortType to the end point.

17 Client Source Code – Explained! (Con’t) The actual call to the service is done on the following line: math.add(10); The service should now register an increase of 10 units. (When the code is ran.)

18 Compile the Client From the command line: javac -classpath \./build/classes/org/globus/examples/services/core/ yourusername_first/impl/:$CLASSPATH \ org/globus/examples/clients/ MathService_instance/Client.java

19 Run The Client From the command line: The output should be similar to: Current value: 15 Current value: 10 java –classpath \./build/classes/org/globus/examples/ services/core/yourusername_first/impl/:$CLASSPATH \ org/globus/examples/clients/MathService_instance/Client \ http://localhost:yourportnumber/wsrf/services/examples/ core/yourusername_first/MathService

20 Undeploy The Service To undeploy the service, run the following from the command line: % sudo -u globus \ globus-undeploy-gar \ org_globus_examples_services_c ore_yourusername_first *The bottom piece is all on one line!

21 What’s Next? Students in the course are asked to extend the functionality of the MathService by adding multiplication capabilities.

22 Conclusion We have –Defined a Globus Web Service using the WSDL –Build the Web Service –Compiled a client for the Web Service –Used the client to contact the Web Service.

23 Questions? Please ask!


Download ppt "Assignment 2 Modifying, Compiling, and Deploying a Simple Service Presenter Information goes Here."

Similar presentations


Ads by Google