### 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 | ## 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.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"/>
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`.