Hello world webservice Step by step explanations

Step 1: Create a dynamic web project “HelloService” like below,

hello webserivce

 

 

Step 2: Create a file named “Hello.java” under src of the above HelloService dynamic project,

public class Hello {
	public String HelloWorld(String input){
		return "Hello"+input;
	}
}

 

Step 3: Now right click on the project(Hello Service) and create the “Web service” like below,

web service for helloservice

 

Hello Webservice has been created successfully, now we will create the client and call the above created service.

Right click on the HelloService and run as server,

running helloservice

 

our hello service

 

helloservice url

Step 4: Create the “HelloClient” dynamic web project.

Step 5: Right click on the above created project and create the “Web service client” like below,

web service client

 

Step 6: Create a HelloTest java file under src of HelloClient dynamic project and paste the below code,

import java.rmi.RemoteException;
import org.apache.axis2.AxisFault;
import org.apache.ws.axis2.HelloStub;
import org.apache.ws.axis2.HelloStub.HelloWorld;
public class HelloTest {
	public static void main(String[] args) throws RemoteException{
		HelloStub hsub = new HelloStub();
		HelloWorld hw = new HelloWorld();
		hw.setInput("naveen");
		String print = hsub.helloWorld(hw).get_return();
		System.out.println(print);
	}
}

¬†Step 7: Run the above program as “Java application”.

Output:

Hellonaveen

 Download the source codes:

HelloClient

HelloService

 

 

 

Thanks for reading this post…………!!!

633 total views, 1 views today

Leave a Reply

Your email address will not be published. Required fields are marked *