Miles to go …

January 23, 2007

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

Filed under: webservices — arungupta @ 8:00 am

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

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • 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 3
  2. Creating and Invoking a Web service using GlassFish in NetBeans, IntelliJ, and Eclipse – Part 2
  3. Tango and Web Service Designer in NetBeans 6
  4. TOTD #98: Create a Metro JAX-WS Web service using GlassFish Tools Bundle for Eclipse
  5. GlassFish v2 supported in IntelliJ Web Services Plugin

20 Comments »

  1. I’m looking forward to the eclipse version of this.
    Thanks

    Comment by sud — January 26, 2007 @ 5:18 pm

  2. If you have any experience with Eclipse, please feel free to blog about it.

    Comment by Arun — January 26, 2007 @ 5:19 pm

  3. [Trackback] In this second part of a blog series (part 1), I plan to explore the steps to develop/deploy/invoke a Web service on GlassFish using IntelliJIDEA IDE. Searching in the help bundled with the IDE on "web service from Java" returned…

    Comment by Arun Gupta's Blog — January 31, 2007 @ 5:13 pm

  4. [Trackback] As I mentioned in my previous post, here are the steps to develop/deploy/invoke a Web service using the Web Services plugin in IntelliJ IDEA. Thanks to AdvancedTools, author of the plugin, for helping me through this process. The Web service…

    Comment by Arun Gupta's Blog — February 1, 2007 @ 8:51 am

  5. [Trackback] One of the big benefits of JAX-WS 2.0 is that deployment descriptors are optional. By optional, it means no deployment descriptors are required if you can live with the reasonable defaults defined by the JAX-WS specification. So if you develop…

    Comment by Arun Gupta's Blog — February 2, 2007 @ 10:12 am

  6. [Trackback] 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…

    Comment by Arun Gupta's Blog — February 5, 2007 @ 9:18 am

  7. Thank you so much. I just found this via Google. Simple, to the point, and works perfectly. Thanks!

    Comment by giesen — April 10, 2007 @ 1:55 pm

  8. [Trackback]
    Het creeeren van een webservice in netbeans6 is een eitje, in ongeveer 5 stappen heb je al een simpele webservice.
    Ik vroeg mij af of ik dat ook zo makkelijk kan in idea6. Helaas moet ik concluderen dat dat toch niet zo makkelijk gaat.
    Doormiddel v…

    Comment by Logic blog — October 14, 2007 @ 12:53 pm

  9. For Eclipse, found this blog is really useful:
    http://weblogs.java.net/blog/vivekp/archive/2007/10/metro_tooling_n.html

    Comment by hanofee — April 30, 2008 @ 12:26 am

  10. hanofee, A complete screencast of creating a Web service using Eclipse 3.3 is available at:

    http://blogs.sun.com/arungupta/entry/screencast_ws6_eclipse_europa_and

    Comment by Anonymous — April 30, 2008 @ 6:43 am

  11. Dear sir,

    Eclipse is throwing me java.lang.NullPointerException . PLz help me out.
    1. Initially a create a dynamic web project and target runtime is set to GlassFish V2 java EE5 2 and config is set to Default Configration for GlassFish V2 java EE 5 2.

    2 In project facets i have set Dynamic Web Module 2.5, java 5.0 and Sun Deployment Descriptors File 9

    3. then created .jsp file under WebContent folder.

    4. I selected jsp template to be html form .

    5. typed helloworld in body and selected Run on server.

    I have started Glassfish Server from terminal also. But now it is throwing me error call glassfish server not started and the same way it sometimes throws java.lang.NullPointerException.

    Please help me out .

    Comment by Priyanka — November 2, 2008 @ 10:10 pm

  12. Hi Priyanka,

    I see you’ve taken your question to the alias:
    — that is the correct place to discuss and I will follow up with you there. Thanks.

    Comment by Rochelle — November 4, 2008 @ 10:54 am

  13. I have started Glassfish Server from terminal also. But now it is throwing me error call glassfish server not started and the same way it sometimes throws java.lang.NullPointerException.

    Comment by laptop battery — November 26, 2008 @ 9:55 pm

  14. Hi,

    I am planning to create a TCP plug-in for Transport (i.e. serializing with TCP format) within Metro service stack on GlassFish using Eclipse. While using TCP/IP, the messages will be typically preceded by 2 bytes, the high byte first, low byte second.

    It will be helpful if you can guide us if there is any provision (in form of API’s) with Metro service stack which we can avail for creation of TCP plug-in for transport.

    Thanks,
    Dushiyant

    Comment by dushiyant — July 3, 2009 @ 6:10 am

  15. Dushiyant,

    Metro has support for SOAP-over-TCP as described at:

    http://blogs.sun.com/oleksiys/entry/tcp_transport_for_web_services

    Are you looking for something else ?

    Comment by Arun Gupta — July 6, 2009 @ 10:01 am

  16. Hi,

    We are not intending to use ‘SOAP/TCP’ due to following reasons -
    1. we don’t want to use ‘Fastinfoset’ which is being used by ‘SOAP/TCP’.
    2. we want to use TCP with 2 bytes header which is not being currently supported by ‘SOAP/TCP’.

    Therefore we are planning to develop a TCP plug-in which can serve us as an alternative to ‘SOAP/TCP’.

    Please guide us as how we can accomplish our purpose by using Metro service stack.

    Thanks,
    Dushiyant

    Comment by Dushiyant — July 6, 2009 @ 11:39 pm

  17. I have a web service generated by adopting ‘Top Down Approach’ and it follows SOAP/HTTP transport. Now I have to use SOAP/TCP instead of SOAP/HTTP.

    Please advise how to enable SOAP/TCP now with minimal changes.

    Thanks,
    Charudatt

    Comment by Charudatt — August 10, 2009 @ 4:55 am

  18. Charudatt,

    Please ask your question at for a broader audience.

    Comment by Arun Gupta — August 11, 2009 @ 10:21 pm

  19. How to change webservice url dynamically when invoking. I need to invoke a webservice which url is not fixed.

    Comment by Ko Min Min — April 28, 2010 @ 1:30 am

  20. Ko Min Min,

    Changing the Web service endpoint location is explained at:

    http://blogs.sun.com/arungupta/entry/totd_2_change_the_endpoint

    Comment by Arun Gupta — May 6, 2010 @ 8:52 am

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