Tuesday, December 7, 2010

Embedding Axis2 into an Existing Application

Many of you may came up with implementing Web Services for existing application, here I have done it using Apache Axis 2, So here what you need to do,

You should edit your web.xml file found in WEB-INF directory, and there you have to configure Axis specific information, (You must configure AxisServlet there, so when the application deploying server will identify that Axis2 is plugged in to this application)

web.xml

    
        Apache-Axis Servlet
        AxisServlet
        
            org.apache.axis2.transport.http.AxisServlet
        
        1
    

Now add servlet mapping,
    
        AxisServlet
        /services/*
    

This will tell the Axis Servlet that all your Web Services will include in a directory called services, So the service URL's must have services text within their URL's

If you do not wish to add your web services in a directory called services, you can change this to something else,

i.e :
    <servlet-mapping>
        <servlet-name>AxisServlet</servlet-name>
        <url-pattern>/serviceapps/*</url-pattern>
    </servlet-mapping>


And you need to tell axis2.xml that where are your services,

axis2.xml
serviceapps
note

Axis2 assumes that all your service implementations are in a directory called services, in WEB-INF folder. so if you are not changing that, you don't have to modify axis2.xml file.

Thats all you have to do, Remember to copy all the JAR files in Axis2 distribution to your WEB-INF/lib directory :)

So when the application deploying in the server, it will initialize the AxisServlet and loads the web service implementations from default locations,

Default Service Location

WEB-INF/services

Default Module Location

WEB-INF/modules

Default Axis2 XML Location

WEB-INF/conf

Directory structure.

2 comments:

  1. Hi,

    Sorry for the late reply.
    You have a public domain or IP?

    ReplyDelete
  2. Hi ,

    Can u pls post the axis2.xml for reference.

    ReplyDelete