風人園

          弱水三千,只取一瓢,便能解渴;佛法無邊,奉行一法,便能得益。
          隨筆 - 99, 文章 - 181, 評論 - 56, 引用 - 0
          數據加載中……

          hessian binary web service protocol(一個簡單的ws包)

          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.

          The Service API

          A Hessian service's API is just a plain old Java interface.

          Hello, World API
          public interface BasicAPI {
          public String hello();
          }
          

          The Hessian protocol eliminates external API descriptions like CORBA IDL files or WSDL. Documenting a Hessian service API is as simple as providing the JavaDoc. Because Hessian is language-independent, the Java interface classes are not required for non-Java languages. For external languages, the Java interfaces serve only to document the service methods.

          Service Implementation

          The service implementation can be a plain-old Java object (POJO) or can extend HessianServlet to make the servlet-engine configuration trivial.

          Hello, World Service
          public class BasicService extends HessianServlet implements BasicAPI {
          private String _greeting = "Hello, world";
          public void setGreeting(String greeting)
          {
          _greeting = greeting;
          }
          public String hello()
          {
          return _greeting;
          }
          }
          

          The service implementation can also be a plain-old Java object (POJO), avoiding any dependency on HessianServlet. More details are at Hessian introduction and in the Hessian Service using Dependency Injection tutorial.

          Client Implementation

          Creating a client is as simple as creating an API interface:

          Hello, World Client
          String url = "http://hessian.caucho.com/test/test";
          HessianProxyFactory factory = new HessianProxyFactory();
          BasicAPI basic = (BasicAPI) factory.create(BasicAPI.class, url);
          System.out.println("hello(): " + basic.hello());

          posted on 2009-05-25 09:49 風人園 閱讀(439) 評論(0)  編輯  收藏 所屬分類: Open Source

          主站蜘蛛池模板: 巴青县| 凉山| 田林县| 瓦房店市| 巴楚县| 美姑县| 松阳县| 宜良县| 益阳市| 轮台县| 怀来县| 浪卡子县| 凤城市| 东明县| 洪雅县| 神池县| 泰兴市| 博兴县| 海丰县| 江门市| 余江县| 通化市| 无棣县| 宜春市| 咸丰县| 垦利县| 二连浩特市| 通化市| 定州市| 南涧| 府谷县| 崇仁县| 丰宁| 屏山县| 隆尧县| 毕节市| 南开区| 石首市| 盐边县| 镇沅| 呼伦贝尔市|