How to create a web service in Eclipse

Home > Search > How-to
  by

Create a dynamic web project. Ensure Eclipse's web service runtime is appropriate for the server runtime being used.

  1. In Eclipse, select WindowPreferences.
  2. In the left panel, expand Web Services and select Server and Runtime

If the dynamic web project is configured to run on WebSphere Liberty, then the web service runtime should be IBM WebSphere JAX-WS.

 

If the dynamic web project is configured to run on Apache Tomcat, then the web service runtime should be Apache Axis.

 

 


Create a package 

  1. In the left panel of Eclipse, expand Java Resources.
  2. Right-click on the src folder and select New > Package.
  3. Give the package a name, such as com.example, and select Finish.

The package should now be displayed in the left panel of Eclipse.

 


Create a class

  1. Right click on the com.example package, and select New Class.
  2. Give the class a name, such as Hello, and select Finish.

The Hello.java class should now be in the com.example package.

 

Add the following markup to the class.

package com.example;

public class Hello {
	public String helloName(String name){
		return "Hello there " + name;
	} 
}

 


Update the class to be a web service

  1. Right-click on the Hello.java class, and select Web Services Create Web Service.
  2. In the dialog box, set the Web service type to Start service and the Client type to Start client and select Finish.



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments