- 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