Web Service Tasks: Quick Reference

This topic describes common tasks you can perform with web services. For more detailed information, click the links in the right column.

To perform this task Follow these steps
Create a project.
  1. Choose the implementation form for your web service.
  2. Choose File > New Project (Ctrl-Shift-N).
  3. Select the right template for your project. 
Add a JAR file to a project's classpath.
  1. In the Projects window, right-click the project node and choose Properties.
  2. Click Libraries.
  3. Click Add JAR and select the JAR file in the file chooser.

    If you also want to attach source code and Javadoc for the JAR file, click Add Library instead.

Set up compilation dependencies between projects.
  1. In the Projects window, right-click the project node and choose Properties.
  2. Click Libraries.
  3. Click Add Project and select the project folder for the project that you want to add to the project's classpath.
Create a JAX-WS web service.
  1. Create a Java Web project.
  2. Right-click the project and choose New > Web Service or New > Web Service from WSDL.
  3. Complete the wizard. If you don't understand the UI, click Help.

See .

Create a RESTful (JAX-RS/Jersey) web service.
  1. Create a Java Web project.
  2. Right-click the project and choose New > RESTful Web Service from Database or RESTful Web Service from Patterns. If you have an existing project with database entity classes, you can use the RESTful Web Service from Entities wizard, but only if you created JAXB annotations for the entity classes.

See .

Create a JAX-WS Service Client
  1. Create a Java Web or Java project.
  2. Right-click the project and select New > Web Service Client (or New > Other > Web Services > Web Service Client). A wizard opens in which you point to a local project or the URL of a remote WSDL. After completing the wizard, your project has a Web Service References node.
  3. Expand the project's Web Service References node.
  4. Drag and drop the web service operation you want from the Web Services Node into your code, depending on the type of client you want to implement:
    • In a plain Java project, drag it into the main class.
    • In a Java Web application, either drag the operation into the JSP file...
    • ...or add a servlet to the Java Web application and drag the operation into the servlet.
  5. Write your implementation code.

See .

Create a Java client for a RESTful web service
  1. Create a Java, Java Web, or NetBeans Module project.
  2. Right-click the project node and select New > Other > Web Services > RESTful Java Client. A wizard opens.
  3. Complete the wizard. You can choose either a RESTful service in a local NetBeans project or you can choose a service that is registered in the IDE.
    • You can register a remote web service with the IDE provided you have the URL of the service's WADL or WSDL file. Open the Services window, right-click the Web Services node and choose Add Web Service.
  4. Code the graphical client, for example in Swing (for a Java application) or in a JSP/JSF file (for a Java Web application).

See .

Build a project.
  1. Make sure that your resources are on the classpath.
  2. Right-click any project node and choose Build.
Clean a project.
  • Right-click the project node and choose Clean Project.
Run a project.
Modify deployment settings.

Do one or both of the following:

  • Change the browser
  • Use the Run tab in the Project Properties dialog box to change the server.
Test a web service.
  • To test a JAX-WS service, go to the Projects window, right-click the web service's node, and select Test Web Service. You must be able to deploy the service to a running target server.
  • To test a RESTful web service, go to the Projects window, right-click the project's node, and select Test RESTful Web Services. You must be able to deploy the service to a running target server. A browser window opens in which you can test different HTTP methods against the web service's nodes.
Debug a project.
  • Right-click any project and choose Debug.
Attach source code to libraries for debugging.

Instead of debugging the source code of a library that you created in the IDE, debug the project where you created the library. But, if you want to debug a library created outside the IDE, do the following:

  1. Choose Tools > Library Manager from the main window.
  2. If the JAR file is not already registered in the Ant Library Manager, create a new library using the Add Library button.
  3. Select the library in the left panel of the Ant Library Manager.
  4. In the Classpath tab, click Add JAR/Folder and specify the location of the JAR file containing the compiled class files. A library can contain multiple JAR files.
  5. In the Sources tab, add the folder or archive file containing the source code.
Add Javadoc to a project.
  1. Choose Tools > Library Manager from the main window.
  2. If the JAR file is not already registered in the Ant Library Manager, register the JAR file as described above.
  3. In the Javadoc tab, click Add ZIP/Folder and specify the location of the Javadoc files.

Legal Notices