<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    溫馨提示:您的每一次轉載,體現了我寫此文的意義!!!煩請您在轉載時注明出處http://www.tkk7.com/sxyx2008/謝謝合作!!!

    雪山飛鵠

    溫馨提示:您的每一次轉載,體現了我寫此文的意義!!!煩請您在轉載時注明出處http://www.tkk7.com/sxyx2008/謝謝合作!!!

    BlogJava 首頁 新隨筆 聯系 聚合 管理
      215 Posts :: 1 Stories :: 674 Comments :: 0 Trackbacks
            baidu百科這樣介紹它:
            Hessian是一個輕量級的remoting on http工具,使用簡單的方法提供了RMI的功能. 相比WebService,Hessian更簡單、快捷。采用的是二進制RPC協議,因為采用的是二進制協議,所以它很適合于發送二進制數據.
            開元百科這樣介紹它:
            Hessian是Caucho開發的一種二進制Web Service協議。采取Apache許可協議. 
            The Hessian binary web service protocol makes web services usable without requiring a large framework, and without learning yet another alphabet soup of protocols. Because it is a binary protocol, it is well-suited to sending binary data without any need to extend the protocol with attachments.
    Hessian是一個精心打造的Web Service實現,它支持Java、C#、Ruby、PHP和Python,又新增了ActionScript。使用Adobe Flash和Flex的RIA開發者們在需要集成業務服務的時候,Hessian應該是一個不錯的選擇。
            既然都它這么神奇,那么我們就又要去認識下這位新朋友。
            項目主頁:http://hessian.caucho.com/
            建議大家仔細認真閱讀下官方網站。
            還是先從helloworld著手。
            它只需要一個jar包即可
            去官方下載適用于java環境下的jar包支持
            hessian-4.0.7.jar   hessian-4.0.7-src.jar
            創建web工程。
            編寫接口:
    package com.hessian.demo.inf;

    public interface HelloWorld {
        
        
    public String sayHelloWorld(String name);
        
    }
            編寫實現類:
    package com.hessian.demo.impl;

    import com.hessian.demo.inf.HelloWorld;

    public class HelloWorldImpl implements HelloWorld {

        
    public String sayHelloWorld(String name) {
            
    return "Hello ,"+name+"Welcome to use hessian ! ";
        }

    }
            配置web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" 
        xmlns
    ="http://java.sun.com/xml/ns/javaee" 
        xmlns:xsi
    ="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation
    ="http://java.sun.com/xml/ns/javaee 
        http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    >
        
    <servlet>
            
    <servlet-name>helloworld</servlet-name>
            
    <servlet-class>com.caucho.hessian.server.HessianServlet</servlet-class>
            
    <init-param>
                
    <!-- 此處hom-api為固定寫法,為HessianServlet中定義的參數詳細可參考HessianServlet -->
                
    <!-- 其值為接口的類長名即 包名+類名 -->
                
    <param-name>home-api</param-name>
                
    <param-value>com.hessian.demo.inf.HelloWorld</param-value>
            
    </init-param>
            
    <init-param>
                
    <!-- 此處hom-class為固定寫法,為HessianServlet中定義的參數詳細可參考HessianServlet -->
                
    <!-- 其值為實現類的類長名即 包名+類名 -->
                
    <param-name>home-class</param-name>
                
    <param-value>com.hessian.demo.impl.HelloWorldImpl</param-value>
            
    </init-param>
        
    </servlet>
        
    <servlet-mapping>
            
    <servlet-name>helloworld</servlet-name>
            
    <url-pattern>/helloworld</url-pattern>
        
    </servlet-mapping>
    </web-app>
            此處web.xml中配置的初始化參數具體可參考HessianServlet的init()方法
    public void init(ServletConfig config)
        
    throws ServletException
      {
        
    super.init(config);
        
        
    try {
          
    if (_homeImpl != null) {
          }
          
    else if (getInitParameter("home-class"!= null) {
        String className 
    = getInitParameter("home-class");
        
        Class homeClass 
    = loadClass(className);

        _homeImpl 
    = homeClass.newInstance();
        
        init(_homeImpl);
          }
          
    else if (getInitParameter("service-class"!= null) {
        String className 
    = getInitParameter("service-class");
        
        Class homeClass 
    = loadClass(className);

        _homeImpl 
    = homeClass.newInstance();
        
        init(_homeImpl);
          }
          
    else {
        
    if (getClass().equals(HessianServlet.class))
          
    throw new ServletException("server must extend HessianServlet");

        _homeImpl 
    = this;
          }

          
    if (_homeAPI != null) {
          }
          
    else if (getInitParameter("home-api"!= null) {
        String className 
    = getInitParameter("home-api");
        
        _homeAPI 
    = loadClass(className);
          }
          
    else if (getInitParameter("api-class"!= null) {
        String className 
    = getInitParameter("api-class");

        _homeAPI 
    = loadClass(className);
          }
          
    else if (_homeImpl != null) {
        _homeAPI 
    = findRemoteAPI(_homeImpl.getClass());

        
    if (_homeAPI == null)
          _homeAPI 
    = _homeImpl.getClass();
          }
          
          
    if (_objectImpl != null) {
          }
          
    else if (getInitParameter("object-class"!= null) {
        String className 
    = getInitParameter("object-class");
        
        Class objectClass 
    = loadClass(className);

        _objectImpl 
    = objectClass.newInstance();

        init(_objectImpl);
          }

          
    if (_objectAPI != null) {
          }
          
    else if (getInitParameter("object-api"!= null) {
        String className 
    = getInitParameter("object-api");
        
        _objectAPI 
    = loadClass(className);
          }
          
    else if (_objectImpl != null)
        _objectAPI 
    = _objectImpl.getClass();

          _homeSkeleton 
    = new HessianSkeleton(_homeImpl, _homeAPI);
          
    if (_objectAPI != null)
        _homeSkeleton.setObjectClass(_objectAPI);

          
    if (_objectImpl != null) {
        _objectSkeleton 
    = new HessianSkeleton(_objectImpl, _objectAPI);
        _objectSkeleton.setHomeClass(_homeAPI);
          }
          
    else
        _objectSkeleton 
    = _homeSkeleton;

          
    if ("true".equals(getInitParameter("debug")))
        _isDebug 
    = true;

          
    if ("false".equals(getInitParameter("send-collection-type")))
        setSendCollectionType(
    false);
        } 
    catch (ServletException e) {
          
    throw e;
        } 
    catch (Exception e) {
          
    throw new ServletException(e);
        }
      }
             編寫客戶端測試代碼:
    package com.hessian.demo.client;

    import com.caucho.hessian.client.HessianProxyFactory;
    import com.hessian.demo.inf.HelloWorld;

    public class HelloWorldClient {
        
        
    public static void main(String[] args) throws Exception{
            
    //servlet的訪問路徑
            String url="http://localhost:8080/hessian/helloworld";
            
    //創建一HessianProxyFactory對象,用法與xfire很像
            HessianProxyFactory proxyFactory=new HessianProxyFactory();
            
    //獲得HelloWorld的實例,傳遞兩個參數依次為:接口.class,該servlet的訪問路徑
            HelloWorld helloWorld=(HelloWorld) proxyFactory.create(HelloWorld.class, url);
            System.out.println(helloWorld.sayHelloWorld(
    "張三"));
        }
    }
            效果圖:


    posted on 2010-09-01 09:24 雪山飛鵠 閱讀(2672) 評論(2)  編輯  收藏 所屬分類: webservice

    Feedback

    # re: Hessian一個輕量級的remoting on http工具[未登錄] 2010-09-01 09:29 匿名
    不錯,歡迎咱們一塊來研究它的源碼。  回復  更多評論
      

    # re: Hessian一個輕量級的remoting on http工具 2010-10-03 15:01 淡茗
    @匿名
    貌似缺失了很多源碼,如com.caucho.hessian.client.HessianProxyFactory 這個類  回復  更多評論
      

    主站蜘蛛池模板: 亚洲日本乱码一区二区在线二产线 | 亚洲精品无码mv在线观看网站 | 亚洲国产成人久久笫一页| 亚洲午夜福利在线视频| 在线视频观看免费视频18| 亚洲不卡在线观看| 性短视频在线观看免费不卡流畅| 亚洲电影唐人社一区二区| 在线免费中文字幕| 亚洲性无码av在线| 成年在线观看免费人视频草莓| 亚洲 欧洲 视频 伦小说| 成人毛片免费观看视频大全| 亚洲国产成人精品无码区花野真一 | 免费大香伊蕉在人线国产| 疯狂做受xxxx高潮视频免费| 全部免费a级毛片| 中文字幕的电影免费网站| 亚洲精品午夜无码电影网| 无码午夜成人1000部免费视频| 亚洲美女免费视频| 成全影视免费观看大全二| 亚洲av色香蕉一区二区三区| 免费一看一级毛片全播放| 九九热久久免费视频| 久久亚洲免费视频| 大地资源免费更新在线播放 | 在线免费观看一区二区三区| 朝桐光亚洲专区在线中文字幕| 亚洲一区二区三区在线视频| 国产猛男猛女超爽免费视频| 亚洲国产中文在线二区三区免 | 中文字幕亚洲一区| 6080午夜一级毛片免费看6080夜福利| 狠狠色伊人亚洲综合网站色 | 日韩亚洲一区二区三区| 麻豆视频免费观看| 曰批全过程免费视频观看免费软件 | 中文字幕日韩亚洲| 国产免费AV片在线播放唯爱网| 免费无遮挡无遮羞在线看|