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

In this third and last part of a blog series (part 1 and part 2), I plan to explore the steps to develop/deploy/invoke a Web service on GlassFish using Eclipse IDE.

Eclipse does not offer GlassFish as a a bundled container. Instead you need to install GlassFish plugin for Eclipse explicitly. The plugin requires WTP 1.0 installed in Eclipse so I did that following the instructions. After installing WTP, I configured GlassFish v2 M4 following rest of the plugin install instructions.

Here are the steps I followed to successfully build and deploy a Web service:

  1. Create a new "Dynamic Web Project" with name "hello" as shown here. Note the target runtime is "GlassFish V2 Java EE 5". Click Next.
  2. Uncheck "Sun DD Files" in "Project Facets" window as shown here. Click "Next" and "Finish" buttons.
  3. In "Projects" pane, expand the "WebContent", "WEB-INF", and open "web.xml" as shown here.
  4. GlassFish has a Deployment Descriptor Web service deployment but Eclipse seems to require "web.xml" for a WAR. So replace the contents of "web.xml" with a simplistic fragment shown below:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns=""
           xmlns:xsi="" version="2.5"
  5. In "Projects" pane, right click on "Java Resources" and create a new package as shown here.
  6. Right-click on the newly created package and add a new class "Hello" as shown here.
  7. Add the @javax.jws.WebService annotation and a method as shown below:
    public class Hello {
      public String sayHello(String name) {
        return "Hello " + name;
  8. Select "Project" menu, "Build All" (default shortcut Ctrl+B).
  9. In "Projects" pane, right-click on the project, select "Run As", "Run on Server". Take the defaults (GlassFish V2 Java EE 5) as shown here. Click "Next" and "Finish" buttons.
  10. The endpoint gets deployed as shown here. This can be verified by clicking on the "Servers" tab, and expanding GlassFish node as shown here. The endpoint is hosted at http://localhost:8080/hello/HelloService?wsdl.

So far we have been able to deploy JAX-WS based Web service on GlassFish. Eclipse allows generating a Web service client using Axis run-time environment only. So as with IntelliJ, if you want to invoke a Web service using JAX-WS, the recommended way is to use NetBeans 5.5.1 to invoke the Web service.

Enjoy Web services deployed on GlassFish in Eclipse! And remember, GlassFish v2 uses Web Services Interoperability Technology (WSIT) that gives you interoperable Web services with Microsoft .NET 3.0 framework.

So if you want first-class Web services support in an industry-grade, cross-platform IDE and deploy it on an open source, production-quality, Java EE5-compatible Application Server, NetBeans IDE is the only choice.

Technorati: NetBeans IntelliJ Eclipse GlassFish Web services WSIT


I can't wait for better support for generating clients for JAXWS. But in the meantime, the way I am doing it now works very well.

First I generated my client using the command line and the wsimport that is included in glassfish. Setting it up with the -p packagename -s src -d build and the URL for the wsdl. Running this from the work directory to the project I wanted to import it into. Refresh the project and everything was great.

So in order to integrate it, I simply created an external launcher, naming it "Generate Java For Web Service name" add in the executable for wsimport and then the parameters (as mentioned above). All in all I'd almost say its easier to regenerate this way than within Netbeans although the initial setup is a little more complicated.

Hope this helps!


Posted by Geoff on July 20, 2007 at 12:16 AM PDT #

Geoff, glad to know you found another way as well! Can you provide more details on "its easier to regenerate this way than within Netbeans" ? In NetBeans regenerate is just a menu click.

Posted by Arun Gupta on July 20, 2007 at 06:49 AM PDT #

You are so right, I'm sorry about that! Yes refreshing the web service couldn't be easier (as is the case for most things in Netbeans!).

I was actually thinking of the Generation Wizard (which is still incredibly easy), where you have to enter the WSDL url and package name. This is why I was saying it was easier to click the external run button on Eclipse. I'm sorry about the confusion.

I love both products quite a bit. I started using Netbeans as soon as it started having all of the wonderful Java EE 5 treats and just started using Eclipse again now that 3.3 has come out.

I keep trying to figure out how I can make Eclipse more Netbeans like and Netbeans more Eclipse like :-) I was bumbed when I couldn't find anyway to get Eclipse to do the JAXWS client, thus I was very happy when I figured out this simple work around.

Thanks again!


Posted by Geoff on July 20, 2007 at 10:38 AM PDT #

Very cool! I'm glad you are liking NetBeans and hope you are enjoying all the screencasts. Let me know if you'd like to see something in NetBeans and Web services support.

Posted by Arun Gupta on July 20, 2007 at 11:03 AM PDT #

The post is really good. Thanks. And...the next step ¿integrating Eclipse with openESB?.

I think that the ESB specification is the future natural context of SOA. Perhaps a good grafical designer for BPEL modules on eclipse is a good start.

Thanks again.

Posted by Antonio Muñiz on August 23, 2007 at 12:05 AM PDT #

Antonio, Have you checked the partners OpenESB directory at ? Particularly Bostech has an Eclipse plugin.

Posted by Arun Gupta on September 11, 2007 at 04:17 AM PDT #

Hi Arun,

This helps.

I was trying to figure out a way of adding authentication parameters at runtime to SOAP header through JAX-WS client.

Is it possible?

Currently , I have created Web-Service client using "drag-drop" functionality in Netbeans 6.0.

I need to add certain parameters in SOAP Header as I am getting SOAPFaultException back.

Thanks for your help.

Oh, i forgot to mention, i am newbie to web-service, so please forgive me if I am asking stupid questions.


Posted by Tom Ethens on February 20, 2008 at 06:56 AM PST #

Tom, you can send additional SOAP headers as described at:


Posted by Arun Gupta on February 20, 2008 at 08:43 AM PST #

Hi Arun,

Thanks for your quick response.

I tried to manipulate my client as per the instructions on link , but still I am getting SoapFaultException back.

Question: How do we actually see during runtime the SOAP message that is going out in Netbeans 6.0

Thanks for your time.

Appreciate your help.


Posted by Tom Ethens on February 21, 2008 at 03:41 AM PST #

Tom, You can view the SOAP messages going over the wire by using one of the logging properties defined at:

Please post your question on Metro forum ( for a broader audience.

Posted by Arun Gupta on February 21, 2008 at 03:56 AM PST #

Thanks for your help, Arun.
I will do that.


Posted by guest on February 21, 2008 at 04:55 AM PST #

Hi Arun,
If iam given a wsdl file and ask to generate a webservice client prog how do i do that .Please help me with this I am using eclipse 3.2 and My eclipse 5.1 and axis2 this is my ,clients specification .Please help me ASAP

Posted by Arun K V on March 05, 2008 at 08:19 PM PST #

Arun K V, You can use NetBeans and it's in-built support for Metro for generating this client. For Eclipse & Axis, you need to ask the question on their forum.

Posted by Arun Gupta on March 06, 2008 at 06:52 AM PST #

Hi Arun,

Do you have any tutorial to invoke a external web service from a bpel process in netbeans?

Posted by Mithun on June 23, 2008 at 01:48 AM PDT #

Post a Comment:
Comments are closed for this entry.

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


« July 2016