Presentation is loading. Please wait.

Presentation is loading. Please wait.

A1.1 Assignment 1 “Deploying a Simple Web Service” ITCS 4010/5010 Grid Computing, UNC-Charlotte B. Wilkinson, 2005.

Similar presentations

Presentation on theme: "A1.1 Assignment 1 “Deploying a Simple Web Service” ITCS 4010/5010 Grid Computing, UNC-Charlotte B. Wilkinson, 2005."— Presentation transcript:

1 A1.1 Assignment 1 “Deploying a Simple Web Service” ITCS 4010/5010 Grid Computing, UNC-Charlotte B. Wilkinson, 2005

2 A1.2 Acknowledgement This 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.

3 A1.3 Task To build, deploy and test a simple web service.

4 A1.4 Tools This assignment uses: –Java 2 platform standard edition –Apache Jakarta Tomcat Java servlet container –Apache Axis tools

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

6 A1.6 Client Web service Apache Tomcat hosting environment

7 A1.7 Step 1 – Implement Service 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.

8 A1.8 Step 1 (continued) Copy the.jws file to the axis directory: cp MyMath.jws \ $CATALINA_HOME/webapps/axis/yourusername %CATALINA is an environment variable specifying the path to the home directory of the Apache Tomcat java servlet container.

9 A1.9 Axis Java Web Service Facility By placing your Java code as a.jws file in your web application directory structure, Axis will automatically find it, compile it, and deploy the methods.

10 A1.10 Axis Java Web Service Facility (cont.) The service is now deployed and can be accessed remotely through it’s URL: :8080/axis/yourusername/… Example http://www.coit-

11 A1.11 However, a client cannot access the service without all the code needed handle the SOAP messages, i.e. the stubs and associated files.

12 A1.12 Can use Java service code as the basis to create the WSDL file using an Axis “Java2WSDL” tool. Then use the WSDL as the basis to create the requires Java files using an Axis “WSDL2Java” tool

13 A1.13 Step 2 Generate files Use the Axis tools to create four Java source files from MyMath.jws with the composite command: java -classpath $AXISCLASSPATH \ org.apache.axis.wsdl.WSDL2Java \ http://localhost:8080/axis/MyMath.jws?wsdl

14 A1.14 Step 2 (continued) Axis finds MyMath.jws file and creates Two source files each holding a Java interface, – and – Two source files each holding a Java class, – – These files are put in a new package in localhost/axis/yourusername/MyMath_jws/ which is in /home/yourusername/WebServices/

15 A1.15 -- Client code -- Service code

16 A1.16 -- Java class used by client to find location of service. -- Java class that converts client service call to form to be sent to service. – client stub.

17 A1.17 Other files deploy.wsdd – WSDD file provided to registry when service deployed. undeploy.wsdd -- for undeploying service

18 A1.18 Files used by service Service stub (skeleton): – used by MyMathSoapBinding

19 A1.19 Structure Client Stub Registry (Locator) StubService Method call/return Request WSDL WSDL WSDD deploy.wsdd undeploy.wsdd MyMath.wsdl Deploy

20 A1.20 Step 3 Compile new source files Compile source files generated by step 2 with: javac -classpath $AXISCLASSPATH \ localhost/axis/yourusername/MyMath_jws/*.java

21 A1.21 Step 4: Write Client Source Below is client code for an earlier version of Axis (1.1). Version 1.2 used in the assignment requires more code. 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)); }

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

23 A1.23 Step 6 Execute Web Service program java -classpath $AXISCLASSPATH MyMathClient 4 The square of 4 is 16

24 A1.24 Step 7 Extend the Web Service Add functionality to the MyMath web service: Add a method that identifies whether a number is even. Add a method that identifies whether a number is prime. Modify MyMath.jws file and repeat all previous steps to test the extended web service.

25 A1.25 Optional/Extra credit For extra credit, create a second web service (say to do a different math operation) and demonstrate a client using two web services. This may not be trivial!

26 A1.26 Submission of Assignment 1 Produce a 4-6 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. The less documentation provided, the fewer partial credit can be given.

27 A1.27 Screenshots To include screen shots from Windows XP, select window, press Alt- Printscreen, and paste to file. Using Suse Linux, can find a screen shot tool at: Start->Utilities->Desktop->KSnapshot.

28 A1.28 Submission continued Submit your document via WebCT PLEASE DO NOT SUBMIT BY EMAIL TO ME!!

29 A1.29 Due Date (Tentative) 11:59 pm Thursday September 8th, 2005 unless you have system problems outside your control. Assignment will not be accepted after the due date unless you can document a valid reason.

30 A1.30 You MUST report any system problems that are preventing you complete an assignment at least 48 hours before the due date so that you can be given an account elsewhere if necessary. No extensions will be allowed if you did not contact us 48 hours before the due date. System Problems

Download ppt "A1.1 Assignment 1 “Deploying a Simple Web Service” ITCS 4010/5010 Grid Computing, UNC-Charlotte B. Wilkinson, 2005."

Similar presentations

Ads by Google