Presentation is loading. Please wait.

Presentation is loading. Please wait.

Creating Web Services Presented by Ashraf Memon Presented by Ashraf Memon.

Similar presentations


Presentation on theme: "Creating Web Services Presented by Ashraf Memon Presented by Ashraf Memon."— Presentation transcript:

1 Creating Web Services Presented by Ashraf Memon Presented by Ashraf Memon

2 2 Overview Writing service classes in Java Generating service Deploying services with Apache Axis Generating client files and testing them

3 3 Writing service classes in Java Service classes are exactly similar to normal Java classes: –Nothing new to learn from development perspective –Any existing Java Class can be converted into web service. Next slide explains fragments of simple Java class which adds two numbers.

4 4 Writing service classes in Java (contd) Class contains 1 function which performs addition. Function signature is public String sum(int num1, int num2) Function implementation is int answer = num1+num2; return "Sum of "+num1+" and "+num2+" is "+answer; Complete class code follows on next slide.

5 5 Writing service classes in Java (contd) public class Math { public String getSum(int num1, int num2){ int answer = num1+num2; return "Sum of ” + num1 + " and "+ num2 + " is ” + answer; } public static void main(String[] args) { int num1=3; int num2=4;

6 6 Writing service classes in Java (contd) Math sampleProgram = new Math(); String reply = sampleProgram.getSum(3,4); System.out.println(reply); }

7 7 Generating Service Download MathService directory from ftp://dotnet.sdsc.edu/CSIG-WS/ ftp://dotnet.sdsc.edu/CSIG-WS/ Save directory to C:\training\user\code Compile Math.java file by typing following at command prompt javac Math.java Run program by typing following at command prompt java Math

8 8 Generating Service (contd) Output should be Sum of 3 and 4 is 7

9 9 Deploying services with Apache Axis Copy generated class file to C:\training\tools\tomcat\webapps\axis\WEB -INF\classes\ Open deployMath.wsdd in Textpad (Explanation by instructor) Close file.

10 10 Deploying services with Apache Axis(contd) Set classpath by typing classpath at command prompt Execute deployment descriptor by typing deploy deployMath.wsdd at command prompt. This deploys webservice on Axis SOAP Server.

11 11 Generating client files and testing them(contd) Compile MathServiceClient.java by typing following at command prompt –javac MathServiceClient.java Execute Client by typing following at command prompt –java MathServiceClient Output should be MathService.getSum(5,6) = Sum of 5 and 6 is 11


Download ppt "Creating Web Services Presented by Ashraf Memon Presented by Ashraf Memon."

Similar presentations


Ads by Google