Web Service

In this example program I will show you how you can make webservices in the Netbeans IDE.

Web Services with NetBeans IDE


Creating webservices in NetBeans.

In this example program I will show you how you can make webservices in the Netbeans IDE. NetBeans IDE provides necessary GUI Tool to help the developers to quickly develop and deploy web services.

In this example we will

a) Develop webservices

b) Test the webservice

c) Develop client and call the webservice there

d) Finally deploy and test the application

Web Service can be added in a Web project or in Ejb project. Netbeans IDE helps the developers to easily develop and test the webservices. It’s easy to make the Web Service program in Netbeans, which has Glassfish server by default.

Web Service program in Web Project
In Netbeans take new web project in figure 1

Web Services Example
     Figure 1


Give project name   webservice1 as shown in figure 2  


Web Services Example
    Figure 2


Select the server name in figure 3

Web Services Example
     Figure 3


Now Rt Click on the Web Service project  in figure 4

Select New->WebService

Web Services Example

   Figure 4


Now give the name of the Web Service and package name  figure 5

Web Services Example
     Figure 5

Now In design view of Web Service  click on Add Operation  in figure 6

Web Services Example
    Figure 6

Here  give the operation name and parameter name and type as shown  in figure 7

Web Services Example 

     Figure 7     


Now in source view change the return null to return “hello ”+name as in figure 8

Web Services Example

   Figure 8

Now Rt Click on the project and deploy it on the server  as in figure 9

Web Services Example
    Figure 9
It will deploy the war file on to the server
Now test the web service program
Rt click on the MyWebService in web services folder and select Test Web Operation as in figure 10

Web Services Example 

    Figure 10

It will open the Web Service  program in browser as in figure 11
Web Services Example

  Figure 11
Click on WSDL File in blue color .It will open the WSDL  file in the browser as in figure 12
Web Services Example
    Figure 12
Now as in fig type the roseindia in the text field and click on show button  as in figure 13

Web Services Example
    Figure 13


It will return hello roseindia
It also give the SOAP request and SOAP response  pf the Web Service  as in figure 14


Web Services Example
   Figure 14


Now make the client file.Client file can be java servlet , jsp  and standalone java file
Start a new web project as in figure 15.
Give project name as Webservice1-client

Web Services Example
Now Rt. Click on the project select NewàWeb Service client

Here  now select the WSDL file of the Web Service as in figure 15
Click on the Browse.

Web Services Example

Now select the webservice1àMyWebService
Web Services Example
     Figure 15

It creates the Client environments for the Web Service   in the given project
Now make a Client   file  by just taking a new Jsp file as in figure 16

Web Services Example
   Figure 16


Give the file name as client.jsp
Rt click  in client.jsp file code  and select  Web Service Client resources -->Call Web Service  Operation in figure 17


Web Services Example
    Figure 17

Select the web service project ->web service file->web service port->operation name  as in figure 18
Web Services Example

   Figure 18
Change   the name =”null”  to  name=”roseindia”  as in figure 19

Web Services Example
   Figure 19

Rt click in client.jsp and select run client.jsp

Web Services Example

Download Code

Share on Google+Share on Google+

Web Service

Posted on: October 21, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: Web Service   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
Hossam Ghareb
December 13, 2011

i'm really love roseindia and they are usually very helpful for me
March 14, 2013
This Example not working

Hi Im trying to implement the web service as mentioned above. Service implemeting working fine, but service cleint implementation is getting failed while adding service method to Servlet. Showing invalid packge or unable to import
August 28, 2012

tahnks its very useful
Komal Sharma
October 18, 2012
Web Service

This is the best tutorial I have ever found to have a practical start up on understanding web services. Thanks a lot!
Prasanna Sreedharan
August 7, 2013
Thanks for the great tutorial

This example works great... Attaching the screenshots helps lot...
Prasanna Sreedharan
August 7, 2013
Thanks for the great tutorial

Thanks for the Great tutorial . Screenshots are highlights in this tutorial....