Create Web Services using Axis Java2WSDL, WSDL2Java and Eclipse for all Servers manually – Part 1

There a lot of Web Service implementations available in market. The most widely used among them is the Axis way of implementation. There are a lot of Examples available in the web to create expose, consume the Web services using the Axis packages. But it is not feasible to work get the Axis complete packages inside corporate offices all of a sudden and yes I faced the same situation.

After some investment of time I found some funky stuff in web to create a Web Service with just a couple of jars in hand and off-course with the help of Eclipse.

Prerequisites:

  1. Eclipse, any version should be ok, but I was using the Eclipse Indigo with Ant installed in it.
  2. The set of jars needed. Jars are included in the Project sample.
    1. axis.jar
    2. commons-discovery-0.2.jar
    3. commons-logging.jar
    4. jaxrpc.jar
    5. log4j-1.2.15.jar
    6. saaj.jar
    7. wsdl4j.jar
    8. The sample web.xml, server-config.wsdd (These will be used later in the development steps).

Steps to develop Web Services:

  1. Create a Dynamic Web Project “SampleWebService” in Eclipse.
  2. Place the above said jars in the WEB-INF/jars folder.
  3. Open the Web.xml file and copy the following contents into it somewhere between tags. These contents are available in the sample attached.
      <servlet>
        <display-name>Apache-Axis Servlet</display-name>
        <servlet-name>AxisServlet</servlet-name>
        <servlet-class>org.apache.axis.transport.http.AxisServlet</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>
        <display-name>Axis Admin Servlet</display-name>
        <servlet-name>AdminServlet</servlet-name>
        <servlet-class>org.apache.axis.transport.http.AdminServlet</servlet-class>
        <load-on-startup>100</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>AdminServlet</servlet-name>
        <url-pattern>/servlet/AdminServlet</url-pattern>
      </servlet-mapping>
  4. Copy the server-config.wsdd next to web.xml file. We will reuse this file once again after complete the business logic of the server.
  5. Now the basic configurations are complete, we have to develop the business logic for the Web Service. In my example I have taken the Old school Calculator sample.
    Click here to go to the next Part of this article.