Search code examples
web-servicessoapapache-axis

Deploy Axis 2 in Tomcat and access your web service in a custom path


I have an Axis2 based web service which I deployed in Tomcat.First I downloaded axis2.war & placed it in Tomcat's webapps folder.It created axis2 folder & its sub-folders.In the WEB-INF sub-folder of Axis2, in the services sub-folder I place my .aar file.Then in my browser I go to http://localhost:8080/axis2. It has a link services, which lists out all the services.Suppose my service is HelloWorldService. So the path where it is accessible is

http://localhost:8080/axis2/services/HelloWorldService

But I do not want to reveal to world that my web service is driven by Axis2. Suppose I want the path to be

http://localhost:8080/abc/services/HelloWorldService

How to do that? Do I have to rename axis2 folder to abc. I also have an web application abc deployed in the same Tomcat. Do I copy content of axis2 sub-folder to abc. I tried that, did not work.


Solution

  • I also have an web application abc deployed in the same Tomcat. Do I copy content of axis2 sub-folder to abc.

    You're thinking in right direction and yes, you have to copy all content(100% is not required, but its better you do it to start with) of the Axis2.war to abc except web.xml.

    You have to merge, axis2.war/WEB-INF/web.xml content with abc/WEB-INF/web.xml, by copying following to respectively inside <web-app> XML tag.

        <servlet>
            <display-name>Apache-Axis Servlet</display-name>
            <servlet-name>AxisServlet</servlet-name>
            <servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>
            <!--<init-param>-->
            <!--<param-name>axis2.xml.path</param-name>-->
            <!--<param-value>/WEB-INF/conf/axis2.xml</param-value>-->
            <!--<param-name>axis2.xml.url</param-name>-->
            <!--<param-value>http://localhost/myrepo/axis2.xml</param-value>-->
            <!--<param-name>axis2.repository.path</param-name>-->
            <!--<param-value>/WEB-INF</param-value>-->
            <!--<param-name>axis2.repository.url</param-name>-->
            <!--<param-value>http://localhost/myrepo</param-value>-->
            <!--</init-param>-->
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet>
            <display-name>Apache-Axis AxisAdmin Servlet (Web Admin)</display-name>
            <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>
    

    Hope it works for you! If it doen't work update your question and I could refocus the answer.