📄 hessian-ws.ietf
字号:
<?xml version="1.0"?><!DOCTYPE rfc SYSTEM "rfc2629.dtd"><rfc category="std" ipr="full3978" docName="hessian.txt"><?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?><?rfc toc="yes" ?><?rfc symrefs="yes" ?><?rfc sortrefs="yes"?><?rfc iprnotified="no" ?> <front> <title>Hessian 2.0 Web Services Protocol</title> <author initials="S." surname="Ferguson" fullname="Scott Ferguson"> <organization>Caucho Technology Inc.</organization> <address> <postal> <street>P.O. Box 9001</street> <city>La Jolla</city> <region>CA</region> <code>92038</code> <country>USA</country> </postal> <email>ferg@caucho.com</email> </address> </author> <author initials="E." surname="Ong" fullname="Emil Ong"> <organization>Caucho Technology Inc.</organization> <address> <postal> <street>P.O. Box 9001</street> <city>La Jolla</city> <region>CA</region> <code>92038</code> <country>USA</country> </postal> <email>emil@caucho.com</email> </address> </author> <date month="August" year="2007" /> </front> <middle> <section title="Introduction"> <t> This document describes the portions of the Hessian 2.0 protocol concerning web services. The document is intended to be read by implementors of Hessian 2.0. Hessian 2.0 supports two types of network communication: remote procedure call (RPC) and message-based. These may also be viewed as synchronous and asynchronous communication. </t> <t> RPC communication is based on "methods" invoked on a server. The method being invoked is specified in a Hessian 2.0 "call". Arguments to these methods are passed in the call and are serialized using the Hessian 2.0 serialization protocol. If the method was successfully invoked, the return value of the method is also serialized using Hessian 2.0 and sent to the client. If the method was not successfully invoked, a "fault" is returned to the client. RPC communication can use any underlying network protocol for transport such as HTTP or TCP. </t> <t> Message-based communication is asynchronous and does not necessarily involve the use of methods, clients, or servers. Messages may or may not receive a response message. Messages simply contain other Hessian 2.0 objects. These may be simple types, aggregates like a list or map, or an "envelope". Envelopes may have headers that specify routing or other special processing information. They may also contain encrypted, signed, and/or compressed data. Thus using messages with envelopes can be useful in cases where end-to-end security is necessary. Message-based communication can also use any underlying network protocol such as HTTP or TCP and may be especially appropriate in queued message systems. </t> </section> <section title="Design Goals"> <t> Unlike older binary protocols, Hessian is both self-describing, compact, and portable across languages. The wire protocol for web services should be invisible to application writers, it should not require external schema or IDL. </t> <t> The Hessian protocol has the following design goals: </t> <list style="symbols"> <t> It must not require external IDL or schema definitions, i.e. the protocol should be invisible to application code. </t> <t>It must be language-independent.</t> <t> It must be simple so it can be effectively tested and implemented. </t> <t>It must be as fast as possible.</t> <t>It must be as compact as possible.</t> <t>It must support Unicode strings.</t> <t> It must support 8-bit binary data (i.e. without encoding or using attachments.) </t> <t> It must support encryption, compression, signature, and transaction context envelopes. </t> </list> </section> <section title="Hessian Grammar"> <figure anchor="messaging_grammar"> <preamble>RPC/Messaging Grammar</preamble> <artwork>top ::= call ::= message ::= reply # RPC-style callcall ::= 'c' x02 x00 method value* 'z'fault ::= 'f' (value value)* 'z' # message/streaming messagemessage ::= 'p' x02 x00 value* 'z' ::= 'P' x02 x00 value* 'z' # RPC method name (possibly mangled for overloading)method ::= 'm' b1 b0 <method-string> # RPC replyreply ::= 'r' x02 x00 value 'z' # successful message/reply ::= 'r' x02 x00 fault 'z' # exception/fault reply </artwork> </figure> </section> <section title="Messages and Envelopes"> <t> Hessian message syntax organizes serialized data for messaging and RPC applications. The envelope syntax enables compression, encryption, signatures, and any routing or context headers to wrap a Hessian message. </t> <list style="symbols"> <t> Call ('c'): contains a Hessian RPC call, with a method name and arguments. </t> <t> Envelope ('E'): wraps a Hessian message for compression, encryption, etc. Envelopes can be nested. </t> <t>Message ('p'): contains a sequence of serialized Hessian objects.</t> <t>Reply ('r'): contains a reply to a Hessian RPC call.</t> </list> <section title="Call"> <figure anchor="call_grammar"> <preamble>Call Grammar</preamble> <artwork>call ::= c x02 x00 m b1 b0 <method-string> value* z </artwork> </figure> <t> A Hessian call invokes a method on an object with an argument list. The object is specified by the container, e.g. for a HTTP request, it's the HTTP URL. The arguments are specified by Hessian serialization. </t> <section title="Methods and Overloading"> <t> Method names must be unique. Two styles of overloading are supported: overloading by number of argumetns and overloading by argument types. Overloading is permitted by encoding the argument types in the method names. The types of the actual arguments must not be used to select the methods. </t> <t>Method names beginning with _hessian_ are reserved.</t> <t> Servers should accept calls with either the mangled method name or the unmangled method name. Clients should send the mangled method name. </t> <section title="Overloading examples"> <figure anchor="overloading_examples"> <artwork>add(int a, int b) -> add_int_intadd(double a, double b) -> add_double_doubleadd(shopping.Cart cart, shopping.Item item) -> add_shopping.Cart_shopping.Item </artwork> </figure> </section> </section> <section title="Arguments"> <t> Arguments immediately follow the method in positional order. Argument values use Hessian's serialization. </t> <t> All arguments share references, i.e. the reference list starts with the first argument and continues for all other arguments. This lets two arguments share values. </t> <section title="Arguments example"> <figure anchor="arguments_examples"> <artwork>bean = new qa.Bean("foo", 13);System.out.println(remote.eq(bean, bean));---c x02 x00 m x00 x02 eq M t x00 x07 qa.Bean x03 foo x9d z R x00 x00 x00 x00 z </artwork> </figure> </section> <t> The number and type of arguments are fixed by the remote method. Variable length arguments are forbidden. Implementations may take advantage of the expected type to improve performance. </t> </section> <section title="Call examples"> <figure anchor="call_example"> <preamble>obj.add2(2,3) call</preamble> <artwork>c x02 x00 # call for Hessian 2.0 m x00 x04 add2 # method "add2" x92 # 2 - argument 1 x93 # 3 - argument 2 z # end of argument marker </artwork> </figure> <figure anchor="reply_example"> <preamble>obj.add2(2,3) reply</preamble> <artwork>r x02 x00 x95 z </artwork> </figure> </section>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -