Create a java project using the created WSDL mentioned post Create a WSDL for a WebService

Initially the project structure will be like mentioned below.


Generate the server code using Axis2CodeGen pluggin :

Select File > Select New > Click Other…

Select Axis2 Code Generator under the Axis2 Wizrds and Click Next

Select Generate the Java Source code from the WSDL file option and Click Next

Provide the WSDL file location eg : /rezsystem/workspace/MathService/src/gradethree/wsdl/GradeThreeMath.wsdl Use Browse button if you need.

CodeGen Option : custom
Generate Service Side Code
Generate a default services.xml
Generate interface for Skeleton

Provide an Output Path (eg : /home/namal/Desktop/WORKS/WS/Math/Grade3). Use Browse button if needed.

Click Finish.

Take generated files to the project

This will generate the files mentioned in the LHS of the below image. Put those files in to the project as mentioned in the RHS.
Here, I have added resources and the server code to a seperate package (gradethree) since I have an intension to add another WebService within this same Project. You need to modify the package declarations in the Server Code and the services.xml


Implement the logics in the GradeThreeMathSkeleton class.

eg : for Addition Operation

public Addition( additionRequest0){

AdditionResponse additionResponse = new AdditionResponse();

int operand1 = additionRequest0.getOperand1();
int operand2 = additionRequest0.getOperand2();

additionResponse.setRemarks("This is enough for Grade Three Addition!");

return additionResponse;


Packaging : Generate the aar and jar files using the build.xml

Ant task :

<echo>Building GradeThreeMath AAR</echo>
<delete dir="${classes}/META-INF" />
<copy toDir="${classes}/META-INF" failonerror="false">
<fileset dir="${resources}/gradethree">
<include name="*.xml" />
<include name="*.wsdl" />
<include name="*.xsd" />

<jar destfile="${lib}/GradeThreeMath.aar">
<fileset dir="${classes}">
<include name="META-INF/**" />

<jar destfile="${lib}/GradeThreeMath.jar">
<fileset dir="${classes}">
<include name="gradethree/**" />

So, this will return the GradeThreeMath.jar and GradeThreeMath.aar as follows.



Deploy :

You can deploy them as mentioned below

Start the server.

WSDL : http://localhost:8081/axis2/services/GradeThreeMath?wsdl

You can test the service using the SOAP UI with above WSDL as below


You can add another service also within the same project, build/package with another ant task and deploy as mentioned in the below project.


Project lin :