Web Services


Web services are the perfect way to share information and even functionality between applications. It provides means to develop client-server applications where the client and application doesn’t need to be even coded on the same programming language! For example you can have a server interacting with a PC or a mobile phone application via web services. Web services are a great way to providing integration of your application with other applications. It also provides means to extend your application like a client for mobile phones. Depending on your application, there are 3 different types of web services:

  • Remote Procedure Calls (RPC)
  • Service Oriented Architecture (SOA)
  • Representational State Transfer (REST)

For more information go here:

NetBeans provides support for all of them. There’s plenty of documentation on how to generate Web Services here: Consumption of RPC Web services is well supported and documented here:

Consuming JAX-WS Web Services

JAX web services are not yet directly supported for RCP. The approach is creating the client in a plain Java project and either copy and paste the source or create a wrapper library. I suggest the later to make things easier for changes on the client by using the current support on the IDE.


To keep things simple we’ll create a simple web service to be consumed by our client.

How to

Here’s our to-do list:

  • Create Web Service for testing
  • Create Web Service client
  • Wrap Web Service Client in a Library module
  • Use client from RCP application

Let's Explain!

All the hard work is already done by the IDE. It all comes down to consume the generated classes in out module. All project folders should not have spaces in them due to a bug: Since the web service type is not supported like RCP Web Services, we need to create a Java Class Library first.

  1. On the IDE select File>New Project. Then Java>Java Class Library.


  1. Select the folder and name of the project and click finish.


  1. Right click the project you just created and select Web Service Client.
  2. The following step will vary depending on what's the source of the Web Service. In our case select Project and browse for the web project containing the web service to consume. Select a package for the generated classes to go into and click finish. Make sure to build the project so the library is generated.

If you use a web project for source the project needs to be opened in the IDE and the deployed.

  1. Now let's wrap the library into a Module. Select File>New Project>NetBeans Modules>Library Wrap Module. (this assumes that a Module Suite already exists, if not create one before this step)
  2. Press Next.
  3. Select the generated library and select finish (See Linking a wrapper with a project for details on how to automate this process) .

At this point we have a client wrapped and part of our module suite. Now let's write the module that will consume the web service.

  1. Right click the module folder within your Suite and select Add New.


  1. Give the module a name making sure there's no spaces on the name/folder.
  2. Finish the Wizard.
  3. On the new module, create a new Top Component (New>Window)
  4. Create the following components:


  1. On the button's action listener put this code:
	int o1, o2;
        	o1 = Integer.valueOf(op1.getText());
        	o2 = Integer.valueOf(op2.getText());
        	result.setText(service.getServicePort().add(o1, o2).toString());

This assumes that op1 and op2 are the files names and result is the output text box.

  1. Create a private global variable for the service like this:

private ServiceService service = new ServiceService();

  1. Now run the project and enjoy the results

Linking a wrapper with a project

See for methods to link the wrapper module with the source project. This will make propagating the changes to the source automatic.

Creating SOAP Web Services

See for instructions to create a SOAP web service.


Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo