CXF java2wsdl Example

CXF JavaToWS Tutorial explains about generating WSDL And Other Artifacts From Web Service Endpoint's Implementation (SEI) Using CXF JavaToWS Tool

I am showing here, an example of generating WSDL,XSD schema using CXF JavaToWS Tool.

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

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

You can copy the implementation class and other domain objects from CXF Web Service Tutorial

(please see the below project structure screenshot)

CXF java2wsdl Example

JavaToWS Tutorial

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

Here I am providing option "-o" which specifies the name of the generated WSDL file, "-createxsdimports" specifying that seperated XSD will be generated and imported inside WSDL, if you are not specified this, complex types will be inlining them into the WSDL. And finally "-wsdl" which specifies to generate the WSDL file.

package com.tool;


//CXF java2wsdl Example
public class JavaToWSCodeGenerator {
public static void main(String[] args) {
try {
JavaToWS.main(new String[] { "-d", "src", "-o", "ChangeStudent.wsdl", "-createxsdimports", "-wsdl",
"com.student.ChangeStudentDetailsImpl" });
("finished %%%%%%%%%%");
} catch (Exception e) {



1 2 Next

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