WSO2 Web Services Framework/Spring - Installation Guide

This guide describes how to build WSF/Spring with the source distribution and the binary distribtion.

Mandatory

        For the Binary Distribution

Deploying a Web Service using WSF/Spring

Building with the binary distribution

The following instrutions will be relative your webapp present in the servlet container's webapps directory.

  1. Copy the jars in the WEB-INF/lib directory to your classpath (WEB-INF/lib directory in a web application)
  2. Insert the following entries in your web.xml
  3.  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <context-param>
    <param-name>contextConfigLocation</param-name>

    <!--Point to the application context of the application -->
    <param-value>/WEB-INF/applicationContext.xml</param-value>

    </context-param>

    <servlet>
    <servlet-name>axis2</servlet-name>
    <servlet-class>
    org.wso2.spring.ws.servlet.SpringAxis2Servlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>

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

  4. Add the following line in your application context (WEB-INF/ in this case) and copy the axisConfig.xml to the relevant location 

    <import resource="axis2Config.xml"/>
  5. Declare a service bean and add your Spring beans to expose them as web services.

  6. Ex :- If you have a Spring bean with the ID "productManager", it can be exposed as follows:

    <bean id="services" class="org.wso2.spring.ws.WebServices">
    <property name="services">
    <list>
    <bean id="bookService" class="org.wso2.spring.ws.SpringWebService">
    <property name="serviceBean" ref="productManager"></property>
    <property name="serviceName" value="TestProductManager"></property>
    </bean>
    </list>
    </property>
    </bean>
  7. To include WS-Security,
    <bean id="services" class="org.wso2.spring.ws.WebServices">
    <property name="services">
    <list>
    <bean id="bookService" class="org.wso2.spring.ws.SpringWebService">
    <property name="serviceBean" ref="secureProductManager"></property>
    <property name="serviceName" value="SecureTestProductManager"></property>
    <property name="modules">
    <list>
    <value>rampart</value>
    </list>
    </property>
    <property name="policyFiles">
    <list>
    <value>policyFileName.xml</value>
    <list>
    <property>
    </bean>
    </list>
    </property>
    </bean>


    NOTE: policyFileName.xml and key file(keyFileName.jks) should be put in  WEB-INF/classes of your web application
  8. See the WSDL of your service by targeting your browser to http://{host}: {port}/ {webapp}/services/ {serviceName} ? wsdl

Building the Source Distribution

  1. Type mvn clean install� in the base directory (where the source was downloaded to).
  2. If, the build fails due to a missing artifact build again by typing mvn clean install -up
  3. A .war file will be created at BASEDIR/modules/webapp/target/ (An exploded version of the .war file will be located at the same location).
  4. Drop the .war file into a servlet container (ex:- Apache-Tomcat 5.5)