How to use Maven2 WSDL2Code plugin in Axis2

Apache Axis2 ships with a lot of useful tools to make web service developer's life easier. Maven2 WSDL2Code plugin is one of them which can be used to generate server side skeletons or client stubs from a given WSDL using a maven pom.xml.
Lets see how this plugin can be used.

Apache Maven2


Create a maven project using maven archetype template (You may ignore this step and use an existing project if you are familiar with maven)

mvn archetype:create -DgroupId=com.test -DartifactId=calculator

This will create a maven project structure as follows.

Step 2

Create a directory (i.e:- resources) at src\main and copy your WSDL file there.
Now, remove the existing contents of the auto-generated pom.xml (calculator\pom.xml) and add the following configuration.

<project xmlns="" xmlns:xsi=""


Note the highlighted elements in the above pom. First we added a new <plugin> to use wsdl2code goal. The WSDL2Code goal takes a set of input parameters as explained here.
In this example, we use 3 configuration parameters.
<packageName> - The generated source will be added to this package
<wsdlFile> - The location of the input wsdl file
<databindingName> - Databinding mechanism used for code generation

Also, we need to add a dependency to Axis2 jars.

Step 3

Go to the root directory of your project structure (i.e:- calculator directory where pom.xml exists) and run the following command.

mvn clean axis2-wsdl2code:wsdl2code

You could find the generated classes at target\generated-sources\axis2\wsdl2code directory.

Note: The sample wsdl used for the above example can be found at


Ye Huang - Home said…
Hi, Charitha:

Thanks for the tips.
However, I am wondering how to dispose several wsdl (different wsdl files, for generating their codes respectively) with this plugin?

Anonymous said…
Thank you so much!!polo shirt men'ssweate,Burberry Polo Shirts lacoste sweater, ralph lauren Columbia Jackets,ski clothing. Free Shipping, PayPal Payment. Enjoy your shopping experience on can find the father who desire fashionable, intellectual mens clothing simultaneously.
Harlan Gray said…
Thanks. Very simple and useful.
Harlan Gray said…
Hi, now I get this error. Can you help me with this?

D:\Harlan\maven_test\calculator>mvn clean axis2-wsdl2code:wsdl2code
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'axis2-wsdl2code'.
[INFO] org.apache.maven.plugins: checking for updates from central
[INFO] org.codehaus.mojo: checking for updates from central
349b downloaded
[WARNING] *** CHECKSUM FAILED - Checksum failed on download: local = '0f56ee033e
f4b78d33722aceb71a09c7ed68183f'; remote = '
CmaJ said…
We have the same problem and fixed it using maven's version 2.2.0. Instead if use 2.2.1 version it doesn't works.

Ugly but true :(

I hope help you.

Harlan Gray said…
Thanks a million. Yes it is very ugly :(

Popular posts from this blog

Common mistakes to avoid in WSO2 ESB - 1 - "org.apache.axis2.AxisFault: The system cannot infer the transport information from the URL"

Working with HTTP multipart requests in soapUI

WS-Reliable messaging with WSO2 WSAS -1