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

          spring集成hessian

          Posted on 2009-05-20 18:12 析木 閱讀(1903) 評論(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目錄下創(chuàng)建一個(gè)文件名格式為Hessian-servlet.xml的配置文件
          <!-- 業(yè)務(wù)類 -->  
          <bean id="hessianService" class="com.weijy.webservice.hessian.HessianServiceImpl"/>  
                     
          <!-- 遠(yuǎn)程服務(wù) -->  
          <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.客戶端調(diào)用
          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在客戶端連接服務(wù),在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一樣去操作了。原來實(shí)現(xiàn)一個(gè)webservice是可以這么簡單的。
          我要啦免费统计
          主站蜘蛛池模板: 云浮市| 满洲里市| 东乡族自治县| 进贤县| 呼伦贝尔市| 辽源市| 浪卡子县| 永吉县| 衡阳市| 沾益县| 赞皇县| 友谊县| 棋牌| 鄂伦春自治旗| 东兰县| 南安市| 桐乡市| 财经| 城固县| 三亚市| 栾川县| 虎林市| 芷江| 清镇市| 牡丹江市| 抚州市| 巴塘县| 休宁县| 建水县| 古交市| 新田县| 大兴区| 桐城市| 增城市| 四川省| 荔波县| 佳木斯市| 青浦区| 连云港市| 宁国市| 桐庐县|