在webxml中的配置
<contextparam>
<paramname>contextConfigLocation</paramname>
<paramvalue>
/WEBINF/config/applicationContextxml
/WEBINF/Hessianservletxml
</paramvalue>
</contextparam>
<servlet>
<servletname>Hessian</servletname>
<servletclass>
orgspringframeworkwebservletDispatcherServlet
</servletclass>
<loadonstartup></loadonstartup>
</servlet>
<servletmapping>
<servletname>Hessian</servletname>
<urlpattern>/hessian/*</urlpattern>
</servletmapping>
必须在WEBINF目录下创建一个文件名格式为Hessianservletxml的配置文件
<! 业务类 >
<bean id=hessianService class=comcjmwebservicehessianHessianServiceImpl/>
<! 远程服务 >
<bean name=/hessianService
class=orgspringframeworkremotingcauchoHessianServiceExporter>
<property name=service ref=hessianService/>
<property name=serviceInterface>
<value>
comcjmwebservicehessianHessianService
</value>
</property>
</bean>客户端调用
String url = localhost:/spring/hessian/hessianService;
HessianProxyFactory factory = new HessianProxyFactory()
HessianService hessianServer =
(HessianService)factorycreate(HessianServiceclass url)
String ret = hessianServersayHello(Raymondchen)
//……若使用spring则可通过 HessianProxyFactoryBean在客户端连接服务在spring的配置中加入
<bean id=hessianService class=orgspringframeworkremotingcauchoHessianProxyFactoryBean>
<property name=serviceUrl value=localhost:/spring/hessian/hessianService/>
<property name=serviceInterface value=comweijywebservicehessianHessianService/>
</bean>
加入以上的配置后就可像使用其他的bean一样去操作了原来实现一个webservice是可以这么简单 的