XFire

Home
Bug/Issue Reporting
Download
FAQ
Get Involved
License
News
Performance
Stack Comparison
Support
Who uses XFire\?
XFire Team

Documentation

Javadocs
Reports
User's Guide
Release Notes

Quicklinks

Aegis Binding
Client
JAXB 2.0
JSR 181 Annotations
Spring

Developers

Developer Space
CVS
Building
Architecture
Interesting Projects
Roadmap
Release Process
JAX\-WS

You may want to use an xml configuration to configure XFire and your services instead of using the API. In such a case, XFire provides support for a "services.xml" file. In the background XFire is using XBean and Spring to wire everything together. That means you can also intermix Spring bean declarations if you want!

Container Support

XFire may already have native support for a container that you are using. If so, you may want to skip ahead to Container Support to achieve better integration with your existing platform. If you dont' know what a container is, containers manage components and configurations for you. Good examples are Spring, Plexus, Loom, PicoContainer, Geronimo, etc.

 

To use a services.xml to configure your services takes 2 steps:

  1. Write the services.xml file
  2. Update your web.xml file

You'll also want to make sure you have the Spring and XBean jars on your classpath!

Write the services.xml file

A simple services.xml looks like so:

<beans xmlns="http://xfire.codehaus.org/config/1.0">

  <service>
    <name>MyService</name>
    <serviceClass>my.service.Class</serviceClass>

    .... other options ...
  <service>
  <service>
    <serviceClass>another.service.Class</serviceClass>
    <inHandlers>
      <handler handlerClass="foo.handlers.InHandler/>
    </inHandlers>
    <outHandlers>
      <handler handlerClass="foo.handlers.OutHandler"/>
    </outHandlers>
  </service>

  <!-- Global handlers -->
  <xfire>
    <inHandlers>
      <handler handlerClass="org.codehaus.xfire.addressing.AddressingInHandler"/>
    </inHandlers>
  </xfire>

</beans>

 

This file should be placed in your classpath at "META-INF/xfire/services.xml". See the services.xml Reference guide for more information.

Update your web.xml file

You will need to switch from using XFireServlet to the XFireConfigurableServlet which looks for services.xml files on the classpath. Modify your web.xml file to look like so:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

  <servlet>
    <servlet-name>XFire</servlet-name>
    <display-name>XFire Servlet</display-name>
    <servlet-class>
        org.codehaus.xfire.transport.http.XFireConfigurableServlet
    </servlet-class>

    <!--
      The servlet will by default look for the configuration on
      the classpath in "META-INF/xfire/services.xml". You can
      override it with this parameter. Seperate multiple configuration files with a comma.
     -->
    <init-param>
      <param-name>config</param-name>
      <param-value>services.xml</param-value>
    </init-param>
  </servlet>

  <servlet-mapping>
    <servlet-name>XFire</servlet-name>
    <url-pattern>/servlet/XFireServlet/*</url-pattern>
  </servlet-mapping>

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

</web-app>