返回首页
当前位置: 主页 > 编程开发 > EJB >

spring集成hessian

时间:2010-05-08 16:39来源: 作者: 点击:
1、在web.xml中的配置context-param param-namecontextConfigLocation/par ...

  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)

顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名:密码: 验证码:点击我更换图片
推荐内容