How To Create Simple Web Service Using Netbeans as IDE

This time, I use Netbeans 8.1 and tomcat 8.0.27 as the server. You can choose other version if you want.

Here is step by step to create the web service using Netbeans as the IDE:

Create new java web project. Choose the server and java EE version that you want. Click Finish.

Right click on the project then choose new -> web service. Here my project hierarchy after add new web service.

Add the operation by right click on web service class -> add operation.


package com.ariestania.example;

import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;

/**
 * @author ariestania.winda
 */
@WebService(serviceName = "HelloBohayWebService")
public class HelloBohayWebService {

    @WebMethod(operationName = "hello")
    public String hello(@WebParam(name = "name") String txt) {
        return "Hello " + txt + " !";
    }

    @WebMethod(operationName = "doSummary")
    public int doSummary(@WebParam(name = "valOne") int valOne, @WebParam(name = "valTwo") int valTwo) {
        return valOne + valTwo;
    }

}

Continue reading “How To Create Simple Web Service Using Netbeans as IDE”

Advertisements