spring配置xfire生成webservice接口 和 调用webservice接口

  • webservice接口生成很简单,先把接口和业务实现的代码写好,然后在spring配置文件里进行相应的配置即可。配置代码如下

 

 < import resource= "classpath:org/codehaus/xfire/spring/xfire.xml" / >

        < bean name= "Receiver" class ="org.codehaus.xfire.spring.ServiceBean">
               < property name= "serviceBean" ref ="receiverImpl" / > receiverImpl是接口的实现bean
               < property name= "serviceClass" value="net.zoneland.sms.gateway.service.Receiver" / > Receiver是接口
        < /bean >

 

调用地址:http://weburl:端口/上下文/services/Receiver?wsdl

 

 

  • webservice接口调用的实现。
只要在spring配置文件中配置xfire客户端工厂bean:
< bean id= "baseWebService" class="org.codehaus.xfire.spring.remoting.XFireClientFactoryBean" abstract="true">
        < property name= "serviceFactory" ref ="xfire.serviceFactory" />
        < property name= "lookupServiceOnStartup" value="false" />
        < property name= "properties">

                < !-- 等待HttpConnectionManager从连接池中返回空闲连接的超时时间 -- >
                < prop key="http.connection.manager.timeout" >${ws.http.connection.manager.timeout} < /prop>
                < !-- 等待建立连接的超时时间 -- >
                < prop key="http.connection.timeout" >${ws.http.connection.timeout} < /prop>
                < !-- 等待服务器返回数据超时时间 -- >
                < prop key= "http.timeout">${ws.http.timeout} < /prop>
                < !-- 连接到单个服务器的连接数上限 -- >
                < prop key="max.connections.per.host" >${ws.max.connections.per.host} < /prop>
                < !-- 连接到所有服务器的连接个数上限 -- >
                < prop key="max.total.connections" >${ws.max.total.connections} < /prop>
            < /props >
        < /property>
    < /bean >

 

然后写一个和webservice接口一样的接口类:
net.zoneland.sms.gateway.service.Receiver
配置到spring配置文件中:
< bean id= "receiveGatewayService" parent="baseWebService">
        < property name= "serviceClass" value="net.zoneland.sms.gateway.service.Receiver" /> 这里的接口方法要和调用的webservice接口一样
                    
        < property name= "wsdlDocumentUrl" value ="${message.receiverBack.url}" />
    < /bean >

 

message.receiverBack.url 就是webservice接口地址 = http://weburl:端口/上下文/services/Receiver?wsdl
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值