熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java開源技術 >> 正文

spring集成hessian

2022-06-13   來源: Java開源技術 

  在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是可以這麼簡單 的


From:http://tw.wingwit.com/Article/program/Java/ky/201311/28904.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.