posts - 14, comments - 15, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          spring集成hessian

          Posted on 2009-05-20 18:12 析木 閱讀(1892) 評論(0)  編輯  收藏 所屬分類: WebService
          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.weijy.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");  
          //.................... 
          若使用spring則可通過 HessianProxyFactoryBean在客戶端連接服務,在spring的配置中加入:
          <bean id="hessianService " class="org.springframework.remoting.caucho.HessianProxyFactoryBean">
             
          <property name="serviceUrl" value="http://localhost:8888/spring2/hessian/hessianService"/>
             
          <property name="serviceInterface" value="com.weijy.webservice.hessian.HessianService"/>
          </bean>
          加入以上的配置后,就可像使用其他的bean一樣去操作了。原來實現一個webservice是可以這么簡單的。
          我要啦免费统计
          主站蜘蛛池模板: 定结县| 中宁县| 海口市| 塔城市| 京山县| 元朗区| 海原县| 濮阳县| 双桥区| 望城县| 秭归县| 宜川县| 黔西县| 陇南市| 宝兴县| 东明县| 旅游| 商洛市| 高密市| 深州市| 揭阳市| 丹东市| 云安县| 清原| 嵊州市| 台湾省| 张家口市| 盈江县| 新乐市| 嘉禾县| 昭觉县| 朔州市| 康平县| 乐至县| 隆子县| 剑阁县| 綦江县| 鹤山市| 石首市| 巴彦淖尔市| 霍山县|