Tuesday Jan 23, 2007

Creating and Invoking a Web service using GlassFish in NetBeans, IntelliJ, and Eclipse - Part 1

GlassFish is supported in NetBeans, IntelliJ IDEA and Eclipse. I'm starting a 3-part blog that will explain my experience in developing, deploying and invoking a Web service in each of these IDEs. Today, I start with NetBeans.

I'm using NetBeans 5.5.1 for the experiment purpose but these features are available NetBeans 5.0 onwards. Here are the steps that I followed.

  1. Install GlassFish: Before you begin, make sure a GlassFish instance is configured in NetBeans. If not, then it can be added by right-clicking on "Servers" in the "Runtime" tab and selecting "Add Server" and picking the directory location where GlassFish is installed. I configured GlassFish v2 b31.
  2. Create a project: Create a new Web application project by selecting "File", "New Project". Take all the defaults.
  3. Add a Web service: Right-click on the project name and select "New", "Web Service ...". Take the defaults and just specify the package name. Click on "Finish" button. The IDE creates a template Web service and adds a new Web services node to your project.
  4. Add an operation: Expand the Web service node and select the newly created Web service. Right-click and select "Add Operation" as shown here.
  5. Implement the logic: Implement the business logic, in this case returning a simple concatenation of strings "Hello " and the parameter.
  6. Deploy the Web service: Right-click on the project and select "Deploy Project".
  7. Invoke the Web service: Once deployed, as reported in the Output window, right click on Web service name in the Projects tab and select "Test Web Service". This brings up a web page in your default browser to test the Web service. You can view the WSDL of the Web service by clicking on "WSDL File" link and invoke it by entering a value in the text box. The result page shows you the result of Web service invocation and SOAP request and response messages.

These steps are described in NetBeans help after I searched on "web service from Java" in the bundled help. Googling for this term (along with NetBeans) gave me Create a Web Service Using NetBeans 5.0 IDE and Consume the Service with Sun Java Studio Creator 2 IDE and Web Services Support in  the NetBeans IDE. Both the links contain the appropriate content and provide all the information required for a newbie to get started.

Next, I'll try with IntelliJ IDEA and Eclipse.

Technorati: NetBeans IntelliJ Eclipse GlassFish Web services

About

profile image
Arun Gupta is a technology enthusiast, a passionate runner, author, and a community guy who works for Oracle Corp.


Java EE 7 Samples

Stay Connected

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today