Generate a JAX-WS Web Service Client from a WSDL document using Apache CXF
Prerequisites:
- Install and configure the Apache CXF runtime environment. See the Requirements and Installation page for more details.
- 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:
- Select
Window > Open Perspective > Java EE from the top level menu to switch to the Java EE perspective.
- Open the Web Service Client by selecting
File
> New > Other... > Web Services > Web Service Client from the top level menu.
- Web Services page:
- Enter the URI to the remote WSDL file that will be used to generate the client.
- Select Java Proxy as the Client type.
- Move the client slider to the Develop client stage.
- Web service runtime: Select Apache CXF 2.x
- Service project: Select the project in your workspace into which Apache CXF will generate the code.
- Click Next > to move to the first Apache CXF wsdl2java Configuration page:
- Output Directory: Specify the source folder in the service project into which the code is generated.
- Package Name: Type the Java package name to use for the generated code.
- Specify WSDL Namespace to Package Name Mappings: Optionally specify WSDL namespace mappings to Java package names.
- 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.
- Binding Files: Specify one or more JAX-WS or JAXB binding files.
- Click Next > to move to the second Apache CXF wsdl2java configuration page which allows you to override the wsdl2java default preferences:
- 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.
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