Assignments Preliminaries Several computers are configured at WCU

  • Slides: 21
Download presentation
Assignments Preliminaries • Several computers are configured at WCU for the assignments. Here, terra.

Assignments Preliminaries • 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 A 1. 1

Assignment 1 “Deploying a Simple Web Service” Acknowledgement This assignment is derived from: “Classroom

Assignment 1 “Deploying a Simple Web Service” Acknowledgement This assignment is derived from: “Classroom Exercises for Grid Services” by A. Apon, J. Mache, Y. Yara, and K. Landrus, Proc. 5 th Int. Conference on Linux Clusters: The HPC Revolution, May 2004. Barry Wilkinson and Mark Holliday, 2004 A 1. 2

Task • To build, deploy and test a simple web service. Barry Wilkinson and

Task • To build, deploy and test a simple web service. Barry Wilkinson and Mark Holliday, 2004 A 1. 3

Tools This assignment uses: – Java 2 platform standard edition – Apache Jakarta Tomcat

Tools This assignment uses: – Java 2 platform standard edition – Apache Jakarta Tomcat Java servlet container – Apache Axis tools Barry Wilkinson and Mark Holliday, 2004 A 1. 4

Steps • Write the Java code to implement the web service. • Use Axis

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 A 1. 5

Web service Client Apache hosting environment Barry Wilkinson and Mark Holliday, 2004 A 1.

Web service Client Apache hosting environment Barry Wilkinson and Mark Holliday, 2004 A 1. 6

Axis Java Web Service Facility • Place a jws (rather than java) file in

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 A 1. 7

Step 1 – Implement Service Using Java write the code for the class that

Step 1 – Implement Service Using Java write the code for the class that provides the web service. This code is: public class My. Math { 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 A 1. 8

Step 1 (continued) Copy the. jws file to the axis directory: cp My. Math.

Step 1 (continued) Copy the. jws file to the axis directory: cp My. Math. 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 A 1. 9

Step 2 Generate WSDL files Use the Axis tools to create four Java source

Step 2 Generate WSDL files Use the Axis tools to create four Java source files from My. Math. jws using the command: java -classpath $AXISCLASSPATH org. apache. axis. wsdl. WSDL 2 Java http: //localhost: 8080/axis/My. Math. jws? wsdl Barry Wilkinson and Mark Holliday, 2004 A 1. 10

Step 2 (continued) Axis finds My. Math. jws file and creates • • Two

Step 2 (continued) Axis finds My. Math. jws file and creates • • Two source files each holding a Java interface, – My. Math. java and – My. Math. Service. java Two source files each holding a Java class, – My. Math. Service. Locator. java – My. Math. Soap. Binding. Stub. java These files are put in a new package in localhost/axis/yourusername/My. Math_jws/ which is in /home/yourusername/Web. Services/ Barry Wilkinson and Mark Holliday, 2004 A 1. 11

Step 3 Compile new source files Compile source files generated by step 2 with:

Step 3 Compile new source files Compile source files generated by step 2 with: javac -classpath $AXISCLASSPATH localhost/axis/yourusername/My. Math_jws/*. java Barry Wilkinson and Mark Holliday, 2004 A 1. 12

Step 4: Write Client Source import localhost. axis. yourusername. My. Math_jws. My. Math. Service.

Step 4: Write Client Source import localhost. axis. yourusername. My. Math_jws. My. Math. Service. Locator; import localhost. axis. yourusername. My. Math_jws. My. Math. Service; import localhost. axis. yourusername. My. Math_jws. My. Math; public class My. Math. Client { public static void main(String args[]) throws Exception { My. Math. Service service = new My. Math. Service. Locator(); My. Math my. Math = service. get. My. Math(); int x = (new Integer(args[0])). int. Value(); System. out. println("The square of " + args[0] + " is " + my. Math. squared(x)); } } Barry Wilkinson and Mark Holliday, 2004 A 1. 13

Step 5 Compile Client code Compile the client source file with: javac -classpath $AXISCLASSPATH:

Step 5 Compile Client code Compile the client source file with: javac -classpath $AXISCLASSPATH: . My. Math. Client. java Barry Wilkinson and Mark Holliday, 2004 A 1. 14

Step 6 Execute Web Service program java -classpath $AXISCLASSPATH My. Math. Client 4 The

Step 6 Execute Web Service program java -classpath $AXISCLASSPATH My. Math. Client 4 The square of 4 is 16 Barry Wilkinson and Mark Holliday, 2004 A 1. 15

Step 7 Extend the Web Service Add functionality to the My. Math web service:

Step 7 Extend the Web Service Add functionality to the My. Math web service: • Add a method that returns whether a number is even. Modify My. Math. jws file and repeat all previous steps to test the extended web service. Barry Wilkinson and Mark Holliday, 2004 A 1. 16

Step 8 (not in handout) Extra Credit • For extra credit, create a second

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 A 1. 17

Submission of Assignment 1 Produce a 2 -4 page Word document. • Includes how

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 A 1. 18

Submission continued • Submit your document to me electronically using the WCU Department of

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 A 1. 19

Hermes Submission System • Go to: http: //www. cs. wcu. edu/~hermes • Select professor

Hermes Submission System • Go to: http: //www. cs. wcu. edu/~hermes • Select professor (Barry Wilkinson), then • Select course (CS 493 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 A 1. 20

Due Date • 11: 59 pm Thursday September 9 th, 2004 unless we have

Due Date • 11: 59 pm Thursday September 9 th, 2004 unless we have system problems. Barry Wilkinson and Mark Holliday, 2004 A 1. 21