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

JSR 181 HandlerMapping

When using JSR 181 Annotations, you don't have to use the exporter as above; you can automatically expose beans annotated with the WebService annotation. First, write an annotated bean:

package org.codehaus.xfire.spring;

@WebService(serviceName = "EchoService")
public class AnnotatedEchoImpl
    @WebMethod()
    public String echo( String echo )
    {
        return echo;
    }
}

Then, a hander mapping in your web application context xfire-servlet.xml, with the annotated bean and a web annotation implementation:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
  <bean id="webAnnotations" class="org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations"/>
  <bean id="handlerMapping" class="org.codehaus.xfire.spring.remoting.Jsr181HandlerMapping">
    <property name="typeMappingRegistry">
      <ref bean="xfire.typeMappingRegistry"/>
    </property>
    <property name="xfire">
      <ref bean="xfire"/>
    </property>
    <property name="webAnnotations">
      <ref bean="webAnnotations"/>
    </property>
  </bean>

  <bean id="annotatedEcho" class="org.codehaus.xfire.spring.AnnotatedEchoImpl"/> 

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

When this handler mapping is used, all annotated beans will be automatically exported at a certain url prefix (by default: /services/). Thus, the annotatedEcho bean will available at /services/EchoService. Make sure your annotated beans are declared after the Jsr181HandlerMapping declaration.