Codehaus XFire
DocumentationQuicklinksDevelopers
Sponsors |
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!
To use a services.xml to configure your services takes 2 steps:
You'll also want to make sure you have the Spring and XBean jars on your classpath! Write the services.xml fileA 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 fileYou 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> |