How to deploy your JAXWS web service in Axis2

Apache Axis2 provides the facility of deploying JAXWS web services. If you have a JAXWS web service which is written using standard JAXWS annotations, this post will help you to deploy your service in Axis2.

Step 1 : Create a .jar file including your .class files with their packages. Structure of a sample service is shown below.


If you have a WSDL for your service, you can include the WSDL in the root level of the jar file and add the “wsdlLocation” within your “@WebService” annotation which is in your service class. And also you have to provide “serviceName” and “portName” as it is in the WSDL. A Sample annotation is shown below.


If you don’t include the WSDL in your service, Axis2 will try to generate the WSDL for you. But it is better to include your WSDL rather than depending on the generated WSDL. For complex services, WSDL generation may fail.

If you have any libraries on which your service is depending on, you can include those in a “lib” folder at the root level of your .jar archive.

Following image shows the root level structure of your .jar file. WSDL and the “lib” folder are optional.


Step 2 : Download Axis2 1.5 binary distribution (or you can build Axis2 trunk from the source) and extract it. Create a AXIS2_HOME/repository/servicejars directory and copy your .jar file which is created in Step 1 into servicejars directory.

Step 3 : JAXWS WSDL generation depends on jaxws-rt.jar and jaxws-tools.jar files. So you have to download them and copy both into the AXIS2_HOME/lib directory.

Step 4 : Start the server using AXIS2_HOME/bin/ (or .bat). You can see an INFO log on the console on the service deployment.

Step 5 : Access http://localhost:8080/axis2/services from your browser. You can see the deployed JAXWS service and you can see the WSDL by clicking on it. Use some tool like “soapui” to invoke the service by providing the WSDL URL.


About isurues
Age : 24 Date of Birth : 05.11.1984 Country : Sri Lanka

5 Responses to How to deploy your JAXWS web service in Axis2

  1. easternwahoo says:

    Good point about generating wsdl before deployment. I’ve had no success getting Axis2 to generate wsdl at run time, even for the sample JAX-WS applications. Every error displays “If you wish Axis2 to automatically generate the WSDL 1.1, then please +set useOriginalwsdl as false in your services.xml” message. But the stack traces indicate various failures including classNotFound errors. I followed the advice about copying jars. But I finally gave up when I got “java.lang.Exception: Error occurred while attempting to read generated schema file { Schema name conflict in collection. Namespace” error.

    Once I gave up and used WSGEN to generate wsdl at build time, it worked.

    With CXF, I can generate wsdl at runtime with no problems.

  2. isurues says:

    Yeah that’s true. Axis2 WSDL generation for JAXWS services cause problems for some complex scenarios. We will be looking into these issues very shortly.


  3. easternwahoo says:

    Are there plans for Axis2 to provide JAX-WS integration with Spring? The other major JAX-WS implementations provide Spring integration already, including the sun reference implementation, and cxf.

  4. says:

    Packaging JAX-WS as jar is NON standard packaging (please see JSR 109). Even if this is elegant and quick way to do things, it distracts audience prom JEE deployment models.

  5. Pingback: How to use MTOM with Axis2 JAX-WS services « Isuru Suriarachchi’s Blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: