天天看点

Spring XFire 集成

web.xml

<context-param>
	         <param-name>contextConfigLocation</param-name>
	         <param-value>classpath:app*.xml</param-value>
	</context-param>
	
	<listener>
	  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	
	<filter>
	  <filter-name>ecd</filter-name>
	  <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
	  <init-param>
	   <param-name>encoding</param-name>
	   <param-value>UTF-8</param-value>
	  </init-param>
	</filter>
	
	<filter-mapping>
	  <filter-name>ecd</filter-name>
	  <url-pattern>/*</url-pattern>
	</filter-mapping>
  
  <servlet>
    <servlet-name>XFireServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>0</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>XFireServlet</servlet-name>
    <url-pattern>/services/*</url-pattern>
  </servlet-mapping>
         

applicationContext.xml

<bean id="wsInterFace" class="com.ws.impl.WsInterfaceImpl"> 	</bean>
      

XFireServlet-servlet.xml

<!--  引入XFire预配置信息  --> 
 <import resource="classpath:org/codehaus/xfire/spring/xfire.xml"/> 
      
      <!--  使用XFire导出器  --> 
<bean id="baseWebService"  class="org.codehaus.xfire.spring.remoting.XFireExporter" 
       			lazy-init="false"  abstract="true" > 
       <property name="serviceFactory" ref="xfire.serviceFactory"/> <!-- 引用xfire.xml中定义的工厂 -->
         <property name="xfire" ref="xfire" />  <!--  引用xfire.xml中的xfire实例  -->
 </bean > 
      
      <!-- 定义访问的url  -->
<bean  class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping" > 
         <property  name="urlMap" >              
             <map>                  
                <entry key="/WsInterface.ws" >                   
                    <ref bean="WsInterfaceService" />                  
                </entry>              
             </map >          
         </property >      
      </bean >      
      
<bean  id="WsInterfaceService"  parent="baseWebService"> 
         <property name="serviceBean"  ref="wsInterFace" />  <!--  业务服务bean   -->
         <property name="serviceClass"  value="com.ws.WsInterface"/> <!-- 业务服务bean的接口类--> 
</bean>