Saturday 17 September 2011

CREATION OF ADDITION WEB SERVICE


CREATION OF ADDITION WEB SERVICE

Aim:
To create a web service for adding few numbers using NetBeans.

Algorithm:
Using the Netbeans API create a project of the type web application.
Create a web service in the project.
Click on the Design tab and design the prototype of the web service.
Click on source tab and modify the application logic of the web service.
Save the project.
Right click on the project and click on deploy and undeploy.
Then test the web service.

STEPS TO CREATE ADDITION WEB SERVICE:

I.STEPS FOR CREATING SERVER SIDE PROJECT:
1.OPEN File->New->NewProject->Web->Web App..click next
2.Give Project name->addserver…then click finish
3.The addserver project will be created in right side.Right click it and choose the following.
Give the web service name as addweb.
4.After this in left side ,the design window choose the add operation
5. Give the following in the opened window for creating operation
Name->add
6.Then in the source add the following code and save it.
package org;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService()
public class addweb {
    /**
     * Web service operation
     */
    @WebMethod(operationName = "add")
    public int add(@WebParam(name = "a")
    int a, @WebParam(name = "b")
    int b) {
        int k=a+b;
        return k;
    }
}
7.Then right click on add addserver and perform undeploy and deploy…after that right click on addweb and do test web service to see the SOAP request and response message.

Give some integers and click add.

0 comments:

Post a Comment