您的位置:首页 > 编程语言 > Java开发

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

2013-12-06 13:07 441 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: