1、在Web.XML中的配置
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/config/applicationContext.xml,
/WEB-INF/Hessian-Servlet.xml
</param-value>
</context-param>
<servlet>
<servlet-name>Hessian</servlet-name>
<servlet-class>
org.springFramework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Hessian</servlet-name>
<url-pattern>/hessian/*</url-pattern>
</servlet-mapping>
2.必须在WEB-INF目录下创建一个文件名格式为Hessian-servlet.xml的配置文件
<!-- 业务类 -->
<bean id="hessianService" class="com.cjm.WebService.hessian.HessianServiceImpl"/>
<!-- 远程服务 -->
<bean name="/hessianService" class="org.springframework.Remoting.caucho.HessianServiceExporter">
<property name="service" ref="hessianService"/>
<property name="serviceInterface">
<value>
com.cjm.webservice.hessian.HessianService
</value>
</property>
</bean>
3.客户端调用
String url = "http://localhost:8888/spring2/hessian/hessianService";
HessianProxyFactory factory = new HessianProxyFactory();
HessianService hessianServer =
(HessianService)factory.create(HessianService.class, url);
String ret = hessianServer.sayHello("Raymond.chen");
//....................
(责任编辑:admin)
|