Generate a JAX-WS Web Service Client from a WSDL document using Apache CXF

Prerequisites:

  1. Install and configure the Apache CXF runtime environment. See the Requirements and Installation page for more details.
  2. Create a Dynamic Web Project and enable it for Apache CXF Web services development as described here: Create a project for CXF Web services.
To generate a JAX-WS client from a WSDL document:
  1. Select Open the Java EE perspectiveWindow > Open Perspective > Java EE from the top level menu to switch to the Java EE perspective.
  2. Open the Web Service Client by selecting Open the new web service client wizardFile > New > Other... > Web Services > Web Service Client from the top level menu.
  3. Web Services page:

    Web Services Client Wizard

    1. Enter the URI to the remote WSDL file that will be used to generate the client.
    2. Select Java Proxy as the Client type.
    3. Move the client slider to the Develop client stage.
    4. Web service runtime: Select Apache CXF 2.x
    5. Service project: Select the project in your workspace into which Apache CXF will generate the code.
  4. Click Next > to move to the first Apache CXF wsdl2java Configuration page:
    1. Output Directory: Specify the source folder in the service project into which the code is generated.
    2. Package Name: Type the Java package name to use for the generated code.
    3. Specify WSDL Namespace to Package Name Mappings: Optionally specify WSDL namespace mappings to Java package names.
    4. Service Name: Specify the name of the WSDL service from which to generate code. The default is to generate code for every service in the WSDL document.
    5. Binding Files: Specify one or more JAX-WS or JAXB binding files.
  5. Click Next > to move to the second Apache CXF wsdl2java configuration page which allows you to override the wsdl2java default preferences:
  6. Click Finish to generate the client.

The generated client will include a main() that when run will connect to the remote service and invoke every operation on that remote service.

Before running the client open the client in the Java Editor and edit the generated arguments used to invoke the operations on the service.

To run the client right-click on the client in the Project Explorer and select Run As > Java Application.

Related tasks

Create a Web Service from a Java implementation bean using Apache CXF
Generate an SEI and a skeleton implementation bean from a WSDL document using Apache CXF