Assignments Preliminaries
description
Transcript of Assignments Preliminaries
Barry Wilkinson and Mark Holliday, 2004 A1.1
AssignmentsPreliminaries
• Several computers are configured at WCU for the assignments. Here, terra.cs.wcu.edu will be used.
• For technical reasons, students using the WCU computers will first ssh into sol.cs.wcu.edu, and from there ssh into terra.cs.wcu.edu.
Barry Wilkinson and Mark Holliday, 2004 A1.2
Assignment 1
“Deploying a Simple Web Service”
AcknowledgementThis assignment is derived from:
“Classroom Exercises for Grid Services” by A. Apon, J. Mache, Y. Yara, and K. Landrus,
Proc. 5th Int. Conference on Linux Clusters: The HPC Revolution, May 2004.
Barry Wilkinson and Mark Holliday, 2004 A1.3
Task
• To build, deploy and test a simple web service.
Barry Wilkinson and Mark Holliday, 2004 A1.4
Tools
This assignment uses:
– Java 2 platform standard edition– Apache Jakarta Tomcat Java servlet
container– Apache Axis tools
Barry Wilkinson and Mark Holliday, 2004 A1.5
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.
Barry Wilkinson and Mark Holliday, 2004 A1.6
ClientWeb service
Apache hosting environment
Barry Wilkinson and Mark Holliday, 2004 A1.7
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.
Barry Wilkinson and Mark Holliday, 2004 A1.8
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.
Barry Wilkinson and Mark Holliday, 2004 A1.9
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
Barry Wilkinson and Mark Holliday, 2004 A1.10
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
Barry Wilkinson and Mark Holliday, 2004 A1.11
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/
Barry Wilkinson and Mark Holliday, 2004 A1.12
Step 3 Compile new source files
Compile source files generated by step 2 with:
javac -classpath $AXISCLASSPATH \localhost/axis/yourusername/MyMath_jws/*.java
Barry Wilkinson and Mark Holliday, 2004 A1.13
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)); }}
Barry Wilkinson and Mark Holliday, 2004 A1.14
Step 5 Compile Client code
Compile the client source file with:
javac -classpath $AXISCLASSPATH:. MyMathClient.java
Barry Wilkinson and Mark Holliday, 2004 A1.15
Step 6 Execute Web Service program
java -classpath $AXISCLASSPATH MyMathClient 4
The square of 4 is 16
Barry Wilkinson and Mark Holliday, 2004 A1.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.
Barry Wilkinson and Mark Holliday, 2004 A1.17
Step 8 (not in handout)Extra Credit
• For extra credit, create a second web service and demonstrate a client using two web services.
Barry Wilkinson and Mark Holliday, 2004 A1.18
Submission of Assignment 1
Produce a 2-4 page Word document.
• Includes how you modified the service (code and explanation).
• Show that you successfully followed the instructions and performs all tasks by taking screen shots and include these screen shots in the document. Number of screen shots is up to you but it should demonstrate your programs worked.
– To include screen shots from Windows XP, select window, press Alt-Printscreen, and paste to file.
Barry Wilkinson and Mark Holliday, 2004 A1.19
Submission continued
• Submit your document to me electronically using the WCU Department of Mathematics and Computer Science electronic submission system called Hermes.
PLEASE DO NOT SUBMIT BY EMAIL TO ME!!
Barry Wilkinson and Mark Holliday, 2004 A1.20
Hermes Submission System• Go to:
http://www.cs.wcu.edu/~hermes
• Select professor (Barry Wilkinson), then
• Select course (CS493 Fall 2004 Grid computing), then
• Select your name, then
• Select your document and select upload.
• A message is displayed as a receipt.
• Also email sent to you.
Barry Wilkinson and Mark Holliday, 2004 A1.21
Due Date
• 11:59 pm Thursday September 9th, 2004 unless we have system problems.