Java Reference
In-Depth Information
Using References in NetBeans to Generate Web
Service Clients
Problem
You have grown tired of manually generating client-side code based on a WSDL from the
command line, and want that to become part of your regular development workflow. You just
want a quick and easy way to generate the portable JAX-WS objects based on a WSDL so that
you can start using the service as you would any other dependency.
Solution
Use NetBeans 6 Web Service References from within a regular Java project.
Discussion
Many modern IDEs come with the ability to create web service references for client projects.
This saves you from some of the error-prone drudgery of performing many manual steps on
the command line. First, set up your client project as a regular Java project and add a ser-
vice reference by pointing to the WSDL location. Then, once you run the clean and build Ant
targets through the IDE, it generally will insert a wsimport step and compile the generated
service client code along with yours, making it available on the classpath. This makes it very
easy to create clients of existing web services and incorporate that code into your project.
Here is how to use a web service reference in NetBeans 6, which is representative of how
various IDEs typically do it:
1. Create a new client project. This could be a web page, but for this example, you'll just
create a regular Java console-based project, and create a class with a main method to run.
2. Right-click on the project name and choose New→Web Service Client.
3. When the wizard comes up, as shown in Figure 4-8 , enter the local or remote WSDL ad-
dress, and a name for the package that you want generated code to be put into.
Search WWH ::




Custom Search