定义接口,这个接口中定义要通过WebService暴露的方法
package org.ccsoft; publicinterface HelloWS { public String sayHello(String sb); }
实现服务
package org.ccsoft; publicclass HelloWSImp implements HelloWS { public String sayHello(String sb) { // TODO Auto-generated method stub return"Hello "+sb; } }
4 配置服务
将上文中实现的服务,加入到spring的配置文件中。
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="helloWS" class="org.ccsoft.HelloWSImp"/> <bean name="helloService" class="org.codehaus.xfire.spring.ServiceBean"> <property name="serviceBean" ref="helloWS"/> <property name="serviceClass" value="org.ccsoft.HelloWS"/> <property name="inHandlers"> <list> <ref bean="addressingHandler"/> </list> </property> </bean> <bean id="addressingHandler" class="org.codehaus.xfire.addressing.AddressingInHandler"/> </beans>
(编辑:aniston)
|