January 15, 2012

Setting up Apache Axis2 in a Web Application

1) Download the required resources for the Apache Axis2 installation from the link here. Unzip the contents of the downloaded zip file.

2) Copy all the jars in the lib folder in the zip file into the WebContent/WEB-INF/lib folder of the web application.

3) Copy the folder axis2-web (and its contents) into the WebContent folder of the web application

4) Copy the conf, modules and services folders into the WebContent/WEB-INF folder of the web application

5) The structure of the Web Application project after the above steps will look like this,

WebAppName
   |
   |--- WebContent
            |
            |--- axis2-web (and all contents of this folder)
            |
            |---WEB-INF
                   |
                   |--- conf (axis2.xml file in this folder)
                   |
                   |--- lib (all jars files in this folder)
                   |
                   |--- modules (*.mar files in this folder)
                   |
                   |--- services (and its contents in this folder)

6) Add the following configuration to the WebContent/WEB-INF/web.xml file of the web application and within its root <web-app> element

<servlet>
   <servlet-name>AxisServlet</servlet-name>
   <servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>
   <load-on-startup>1</load-on-startup>
</servlet>
<servlet>
   <servlet-name>AxisAdminServlet</servlet-name>
   <servlet-class>org.apache.axis2.webapp.AxisAdminServlet</servlet-class>
</servlet>
    
<servlet-mapping>
   <servlet-name>AxisServlet</servlet-name>
   <url-pattern>/servlet/AxisServlet</url-pattern>
</servlet-mapping>

<servlet-mapping>
   <servlet-name>AxisServlet</servlet-name>
   <url-pattern>*.jws</url-pattern>
</servlet-mapping>

<servlet-mapping>
   <servlet-name>AxisServlet</servlet-name>
   <url-pattern>/services/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
   <servlet-name>AxisAdminServlet</servlet-name>
   <url-pattern>/axis2-admin/*</url-pattern>
</servlet-mapping>

<mime-mapping>
   <extension>inc</extension>
   <mime-type>text/plain</mime-type>
</mime-mapping>

<welcome-file-list>
   <welcome-file>index.jsp</welcome-file>
   <welcome-file>index.html</welcome-file>
   <welcome-file>/axis2-web/index.jsp</welcome-file>
</welcome-file-list>

<error-page>
   <error-code>404</error-code>
   <location>/axis2-web/Error/error404.jsp</location>
</error-page>

<error-page>
   <error-code>500</error-code>
   <location>/axis2-web/Error/error500.jsp</location>
</error-page>


7) Deploy the Web Application to the server. Test the installation was successful by accessing the following URL through the browser,

http://localhost:8080/WebAppName/axis2-web/index.jsp

8) Click on the links - Services, Validate and Administration - and check each of the links work.

Note: Use admin/axis2 as username/password to log in as Administrator

Note: If Validate link displays an error message for the Version service, resolve the error from this post here

9) Invoke the Version Web Service with this URL in the browser:

http://localhost:8080/WebAppName/services/Version/getVersionRequest

No comments:

Post a Comment