Generating a JAX-WS Web Service Client

See Also 

A web service can be consumed in a web application, a Java application, or a MIDP client (MIDlet). For information on consuming web services in a MIDlet, see the Java ME Mobility documentation.

For JAX-WS clients, all imported WSDL files and schemas are resolved automatically by the IDE. For JAX-RPC clients, before you begin, note that if the WSDL file that you want to use imports schemas, other WSDL files, or both, from the local file system, the web service client will only work if the imported schemas and WSDL files are copied beforehand into the WEB-INF/wsdl (or META-INF/wsdl) folder. If you do not do this, the wscompile tool will not be able to locate these imported files at the end of the procedure below.

To create a web service client:

  1. Create the project to contain the web service client. Depending on how you want to consume the web service, create a web application project or a Java application project.
  2. From the Projects window or Files window, right-click a node in the project and choose New > Other. The New File wizard appears. Under Categories, select Web Services. Under File Types, select Web Service Client. Click Next.
  3. Access the WSDL file of the web service that the web service client is to consume. Depending on what the provider has distributed, do the following:
  4. Optionally, specify the package where the client files will be generated. When you complete the wizard, you can find the generated client files in the Projects window, in the Generated Sources node of the client project, or in the Files window, within the build folder.

    If you do not specify a package name, the IDE generates the client files in the default package, which is based on the namespace in the WSDL. You can change this package name later in the WSDL Customization editor.

  5. Specify whether to use JAX-WS or the older JAX-RPC client style. JAX-WS is selected by default. However, older services may require JAX-RPC clients. Install the JAX-RPC Web Services plugin to create JAX-RPC clients.

    If you are creating a client in a J2EE 1.4 web application, the RPC style is automatically selected, and additional options for Client Type appear. See JAX-RPC Clients in J2EE 1.4 Web Applications.

  6. If you want to use raw XML messages when invoking the web service, select Generate Dispatch Code. The client code is generated using the java.xml.ws.Dispatch interface instead of the usual service endpoint interface. This is an advanced feaure and is unselected by default.
  7. Click Finish.

JAX-RPC Clients in J2EE 1.4 Web Applications

If you are creating a web service client in a J2EE 1.4 web application, a Client Type drop-down list appears with the following options:

See Also
About Web Service Clients
About Web Services

Legal Notices