返回 登录
0

maven 项目使用xfire来编写webservices

第一步:
service pom.xml中依赖所需要的jar
-dependency>
-groupId>org.codehaus.xfire-/groupId>
-artifactId>xfire-all-/artifactId>
-version>1.2.6-/version>
-/dependency>
-dependency>
-groupId>org.codehaus.xfire-/groupId>
-artifactId>xfire-spring
-version>1.2.6
-exclusions>
-exclusion>
-artifactId>junit
-groupId>junit
-/exclusion>
-exclusion>
-artifactId>spring-/artifactId>
-groupId>org.springframework-/groupId>
-/exclusion>
-/exclusions>
-/dependency>
第二步:
src/main/resources中添加xfire-beans.xml文件
-?xml version=”1.0” encoding=”UTF-8”?>


<!-- <bean id="webAnnotations"
    class="org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations" />
<bean id="jsr181HandlerMapping" class="org.codehaus.xfire.spring.remoting.Jsr181HandlerMapping">
    <property name="xfire" ref="xfire" />
    <property name="webAnnotations" ref="webAnnotations" />
</bean> -->

<bean id="baseWebService" class="org.codehaus.xfire.spring.remoting.XFireExporter" lazy-init="false" abstract="true">       
    <property name="serviceFactory" ref="xfire.serviceFactory"/>        
    <property name="xfire" ref="xfire" />   
</bean>
<bean id="getPayMoney" class="com.gsoft.modules.hzsj.service.impl.GetPayMoneyServiceImpl"></bean>   
<bean id="getPayMoneyService" parent="baseWebService">      
    <property name="serviceBean" ref="getPayMoney"/>        
    <property name="serviceClass" value="com.gsoft.modules.hzsj.service.GetPayMoneyService"/>   
</bean>


第三步:
编写webservices接口方法
@WebService
public interface GetBudgetsMoneyService {
@WebMethod
public String getBudgetsMoney(
@WebParam(name = “year”) Integer year,
@WebParam(name = “fileno”) String fileno,
@WebParam(name = “entercode”) String entercode,
@WebParam(name = “entername”) String entername,
@WebParam(name = “programname”) String programname,
@WebParam(name = “programtypename”) String programtypename,
@WebParam(name = “economycode”) String economycode,
@WebParam(name = “functioncode”) String functioncode,
@WebParam(name = “resourcename”) String resourcename,
@WebParam(name = “flag”) String flag
);

如此即可。

评论