Embedding Apache Axis2 into Existing Applications, Page 2
The folder structure of the application should be something like what's shown in Figure 1.
Figure 1: Application directory structure
All the required Web services for the application need to be in the services directory. In the same way, all Axis2 modules have to be put into the modules directory. The "conf" directory will contain the default axis2.xml. If you want do any modification, you will need to change that.
Where to Add the Resource and Lbraries
Once you follow the steps above, you have completed the process of all the configurations required to embed Axis2 to an existing application. Now,look at how you are going to share the libraries.
If your services and modules need to share any library, you need to put those files into "WEB-INF/lib" or the application's "lib" directory. All the Axis2 depended .jar files should be in the application library directory or system class path.
Hot Update and Hot Deployment
The next question you may have is about the service hot deployment feature in Axis2. Interestingly, hot deployment and hot update features will continue to work unless you change axis2.xml. In other words, if your application does not have an unwanted problem due to service hot deployment and service hot update, change the following parameters in axis2.xml.
<parameter name="hotdeployment">true</parameter> <parameter name="hotupdate">false</parameter>
Working with a Remote Repository
So far, I discussed how to integrate Axis2 into an application where it uses a repository in the application itself. However, you can configure Axis2 to work with the remote repository; the Axis2 repository could be a URL in this case. You also can have axis2.xml in a remote location as well. For this feature, you need to update the web.xml by adding the init parameters.
<servlet> <servlet-name>AxisServlet</servlet-name> <display-name>Apache-Axis Servlet</display-name> <servlet-class> org.apache.axis2.transport.http.AxisServlet </servlet-class> <!--<init-param>--> <!--<param-name>axis2.xml.url</param-name>--> <!--<param-value> http://localhot/myrepo/axis2.xml </param-value>--> <!--<param-name>axis2.repository.url</param-name>--> <!--<param-value>http://localhot/myrepo</param-value>--> <!--</init-param>--> <load-on-startup>1</load-on-startup> </servlet>
If you want your system to work using a remote axis2.xml, add the following parameter with the value of your axis.xml location.
In the same way, if you want your system to work using a remote repository, add the following parameter with the value you want.
In this article, I discussed how to embed Axis2 into an existing application; there I covered all the necessary configuration and locations needed to add services, modules, and their resources. At the end of the article, I discussed how to embed Axis2 into your application so that it uses a remote repository.
About the Author
Deepal Jayasinghe is a computer science graduate student at Georgia Tech and an Apache Member. Before joining Georgia Tech, he worked at WSO2 for about three years. His interest is mainly in SOA and Distributed computing specially Web services. Deepal was a key member who designed, developed, and implemented the de-facto Java Web service framework, Axis2.
In addition to Axis2, he has contributed to a number of other open source projects, such as Apache Axiom, Apache Synapse, WSO2 Registry, WSO2, and WSAS.