详细文章查看:http://www.voidcn.com/article/p-ryvzpgfl-bgw.html
XFire与Spring结合配置WebService有两种形式:
一、 使用XFire导出器配置
二、? 使用JSR 181注解导出Web Service
applicationContext.xml文件配置
<beans> <!-- ①引入XFire预配置信息 --> <import resource="classpath:org/codehaus/xfire/spring/xfire.xml" /> <!--②使用XFire导出器 --> <!-- ############## 一、 使用XFire导出器配置一个webservice名称为BbtForumService ###################### --> <bean id="BbtForumService" class="org.codehaus.xfire.spring.remoting.XFireExporter"> <property name="serviceFactory" ref="xfire.serviceFactory" /><!--②-1:引用xfire.xml中定义工厂--> <property name="xfire" ref="xfire" /><!--②-2:引用xfire.xml中定义的xfire实例--> <property name="serviceBean" ref="bbtForum" /> <!-- ②-3:业务服务Bean--> <property name="serviceClass" value="com.baobaotao.xfire.server.BbtForumService" /><!--②-4:业务服务Bean的窄接口类--> <property name="name" value="BbtForumServiceUT"/><!--②-5:Web Service名称--> </bean> <bean id="bbtForum" class="com.baobaotao.xfire.server.BbtForum" /> <!-- ############## 二、 使用JSR 181注解导出Web Service ########## --> <!-- ①该Bean获取Spring容器中所有标注@WebService的Bean --> <bean id="webAnnotations" class="org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations" /> <!-- ②对标注@WebService的Bean进行处理,完成导出工作 --> <bean id="jsr181HandlerMapping" class="org.codehaus.xfire.spring.remoting.Jsr181HandlerMapping"> <property name="xfire" ref="xfire" /> <property name="webAnnotations" ref="webAnnotations" /> </bean> </beans>
?web.xml文件配置项:
<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value><!-- ①刚才配置的Spring文件 --> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <servlet><!--②配合Spring容器中XFire一起工作的Servlet --> <servlet-name>xfireServlet</servlet-name> <servlet-class> org.codehaus.xfire.spring.XFireSpringServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>xfireServlet</servlet-name> <url-pattern>/service/*</url-pattern><!--③在这个URI下开放Web Service服务 --> </servlet-mapping>
?根据cb_121的详细讲解自己一步步整理了做一个记录方便以后用到。
?非常感谢cb_121,谢谢!
查看他的博客主页:http://blog.csdn.net/cb_121
?
重新更新了支持用户名和密码校验但是具体还是没搞清楚,留待以后再详细理清思路再完善。后台代码不包含jar包如需联系:zhangyq1011@gmail.com