Miles to go …

February 5, 2007

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

Filed under: eclipse, netbeans, webservices — arungupta @ 8:00 am

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

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot
Related posts:
  1. Creating and Invoking a Web service using GlassFish in NetBeans, IntelliJ, and Eclipse – Part 1
  2. Creating and Invoking a Web service using GlassFish in NetBeans, IntelliJ, and Eclipse – Part 2
  3. TOTD #98: Create a Metro JAX-WS Web service using GlassFish Tools Bundle for Eclipse
  4. Screencast #WS2: Invoking a Web service using NetBeans IDE
  5. GlassFish v2 supported in IntelliJ Web Services Plugin


  1. 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!


    Comment by Geoff — July 20, 2007 @ 7:16 am

  2. 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.

    Comment by Arun Gupta — July 20, 2007 @ 1:49 pm

  3. 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!


    Comment by Geoff — July 20, 2007 @ 5:38 pm

  4. 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.

    Comment by Arun Gupta — July 20, 2007 @ 6:03 pm

  5. 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.

    Comment by Antonio Muñiz — August 23, 2007 @ 7:05 am

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

    Comment by Arun Gupta — September 11, 2007 @ 11:17 am

  7. 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.


    Comment by Tom Ethens — February 20, 2008 @ 2:56 pm

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


    Comment by Arun Gupta — February 20, 2008 @ 4:43 pm

  9. 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.


    Comment by Tom Ethens — February 21, 2008 @ 11:41 am

  10. 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.

    Comment by Arun Gupta — February 21, 2008 @ 11:56 am

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


    Comment by Anonymous — February 21, 2008 @ 12:55 pm

  12. 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

    Comment by Arun K V — March 6, 2008 @ 4:19 am

  13. 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.

    Comment by Arun Gupta — March 6, 2008 @ 2:52 pm

  14. Hi Arun,

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

    Comment by Mithun — June 23, 2008 @ 8:48 am

  15. Mithun,

    A quick Google gave me the following links:

    Comment by Arun Gupta — June 23, 2008 @ 9:51 am

  16. Can you point me to information as to how to start using GlassFish OpenESB with Eclipse? I’m using GlassFish Tools Bundle prelude v3 with Eclipse using Axis runtime. All is working well for PO Services. Would like to move into a “Hello World” example using OpenESB.


    Comment by Lew Pearson — October 1, 2009 @ 1:36 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.
Powered by WordPress