Hello world webservice Step by step explanations
Step 1: Create a dynamic web project “HelloService” like below,
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,
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,
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,
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:
Thanks for reading this post…………!!!