xfire建立webservice服务
spring和xfire所需的jar包自己寻找下载,我这里用的是xfire1.2.6,spring好像是2.5的
配置xfire和spring集成,需要一个xfire-servlet.xml文件,其实就是spring的.xml文件,命名空间和方式与spring一致
xfire-servlet.xml源码如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<!--xfire必须的配置,不知道是什么意思-->
<import resource="classpath:org/codehaus/xfire/spring/xfire.xml" />
</pre><pre name="code" class="html"><span style="white-space:pre"> </span><!-- 服务所需的类,交由spring管理 根据自己的情况进行设置就可以了,我这里直接粘贴我的代码了 开始 -->
<bean id="jdbcmsg" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="msg"></property>
</bean>
<bean id="androdao" class="webservice.dao.AndroDao" scope="prototype">
<property name="jdbc" ref="jdbccons"></property>
<property name="jdbcmsg" ref="jdbcmsg"></property>
</bean>
<bean id="synem" class="webservice.impl.EmployeeImpl" scope="prototype">
<property name="xmlpar" ref="xmlparse"></property>
<property name="dao" ref="androdao"></property>
</bean>
<!-- 服务所需的类,交由spring管理 结束 -->
</pre><span style="white-space:pre"></span><pre name="code" class="html"><!-- xfire服务暴露的配置 -->
<beanclass="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"><property name="urlMap"><map>
<!-- 服务 -->
<entry key="/SynWebService"><ref bean="synser" /></entry></map></property></bean>
<!-- 服务配置 -->
<bean id="synser"
class="org.codehaus.xfire.spring.remoting.XFireExporter">
<property name="serviceFactory">
<ref bean="xfire.serviceFactory" />
</property>
<property name="xfire">
<ref bean="xfire" />
</property>
<property name="serviceBean">
<ref bean="synem" />
</property>
<property name="serviceClass">
<value>webservice.Iemployee</value>
</property>
<!-- 服务名 -->
<property name="name" value="OA_TYYHZX_MMTB_SERVICE"></property>
<!-- 身份验证,下一贴有具体内容 -->
<property name="inHandlers" ref="auth"/>
</bean>
<bean id="auth" class="webservice.XfireHandler" scope="prototype"></bean>
</beans>
这样xfire就配置好了
只需完善服务接口和实现类了,这里由于项目原因保密,你可以通过一个helloworld的简单类去建立接口和实现类进行测试