XFire

Home
Bug/Issue Reporting
Download
FAQ
Get Involved
License
News
Stack Comparison
Support
User's Guide
XFire Team

M5

Javadocs
Reports

M6-SNAPSHOT

Javadocs
Reports

Developers

Developer Space
CVS
Building
Architecture
Interesting Projects
Release Process

This page outlines how to set up XFire for use via Spring's Remoting framework.

Setup the DispatcherServlet in the web.xml:

You'll need to include the DispatcherServlet in your web.xml. Notice that it provides the locations of where your spring beans are.

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml
        <!-- The XFire Spring Beans Configuration -->
    classpath:org/codehaus/xfire/spring/xfire.xml</param-value>
</context-param>

<context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>/WEB-INF/log4j.properties</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
    <servlet-name>xfire</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>xfire</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

Remote Exporter

When using a RemoteExporter, you should define a service interface and (at least) one implementation of that interface.

Service Interface

package org.codehaus.xfire.spring.example;

/**
 * Provides the service contract for the echo service.
 *
 * @author <a href="mailto:poutsma@mac.com">Arjen Poutsma</a>
 */
public interface Echo
{
    String echo(String in);
}

Service Implementation

package org.codehaus.xfire.spring.example;

/**
 * Provides a default implementation of the echo service interface.
 */
public class EchoImpl
        implements Echo
{
    public String echo(String in)
    {
        return in;
    }

}

XFireExporter

Then, you'll need to create a exporter definition for the service you want to expose. Typically, you'll do this in the servlet context configuration file. Since the dispatcher servlet is named xfire, this file should be called xfire-servlet.xml.

<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="urlMap">
        <map>
            <entry key="/EchoService">
                <ref bean="echo"/>
            </entry>
        </map>
    </property>
</bean>

<!-- Declare a parent bean with all properties common to both services -->
<bean id="echo" class="org.codehaus.xfire.spring.remoting.XFireExporter">
    <property name="serviceFactory">
        <ref bean="xfire.serviceFactory"/>
    </property>
    <property name="xfire">
        <ref bean="xfire"/>
    </property>
    <property name="service">
        <ref bean="echoBean"/>
    </property>
    <property name="serviceInterface">
        <value>org.codehaus.xfire.spring.example.Echo</value>
    </property>
</bean>

Thus, the methods defined in the Echo interface are exposed at the path /EchoService, backed by the EchoImpl bean.