CXF wsdl2java Example

CXF wsdl2java Example explains about Generating Java Code From WSDL Document (WSDL) Using CXF wsdl2java Tool.

You can also use this tool for creating client proxy and invoking the web service

I am showing here, an example of generating annotated java code from WSDL document using WSDL To Java tool.

You can also generate server side and client side code using this tool, you can go to below reference

You can see how to generate java codes by following wsdl2java sample

Reference ->

Required Libraries

You need to download

  1. JDK 6
  2. Eclipse 3.7
  3. CXF-2.7.3

Following jar must be in ClassPath

  1. commons-collections-3.2.1.jar
  2. commons-lang-2.6.jar
  3. commons-logging-1.1.1.jar
  4. cxf-2.7.3.jar
  5. httpasyncclient-4.0-beta3.jar
  6. httpclient-4.2.1.jar
  7. httpcore-4.2.2.jar
  8. httpcore-nio-4.2.2.jar
  9. jaxb-impl-2.2.6.jar
  10. jaxb-xjc-2.2.6.jar
  11. neethi-3.0.2.jar
  12. velocity-1.7.jar
  13. wsdl4j-1.6.2.jar
  14. xmlschema-core-2.0.3.jar

For generating WSDL you can either deploy CXF Web Service Tutorial or you can copy WSDL and Schema files from CXF java2wsdl Example

If you gone for first option, then you can directly provide WSDL "http://localhost:8080/CXFTutorial/ChangeStudent?wsdl", if you are opted for second, ie; copying WSDL & Schema then you need to add this WSDL & Schema on root folder of the project as ChangeStudent.wsdl

We are going through the second approach ie; copying WSDL & Schema (see the project structure)

please see the below project structure

wsdl2java Example


I am going to call WSDLToJava class from main method, you can also invoke WSDLToJava from command line too.

Here I am providing option "-d" which specifies the where the files need to be generated (In this example, it is generated inside src).

package com.tool;


// CXF wsdl2java Example
public class WSDLToJavaCodeGenerator {
public static void main(String[] args) {
try {
// you can also specify WSDL directly like http://localhost:8080/CXFTutorial/ChangeStudent?wsdl
WSDLToJava.main(new String[] { "-d", "src", "ChangeStudent.wsdl" });
("finished %%%%%%%%%%");
} catch (Exception e) {



After running the above main class, you can see the generated java code (selected package) on following screenshot

wsdl2java Example

6 Responses to "CXF wsdl2java Example"
  1. alkiviadis 2012-09-16 10:06:17.0
  1. alkiviadis 2012-09-17 10:06:17.0
  1. admin 2012-09-18 10:06:17.0
  1. alkiviadis 2012-09-19 10:06:17.0
  1. Redmond 2012-09-20 10:06:17.0
  1. admin 2012-09-21 10:06:17.0

Your email address will not be published. Required fields are marked *