📄 hessian-1.0-spec.xtp
字号:
<def>call ::= c x01 x00 <var>header</var>* m b16 b8 method-string (<var>object</var>)* z</def><example title="obj.add2(2,3) call">c x01 x00 m x00 x04 add2 I x00 x00 x00 x02 I x00 x00 x00 x03 z</example><example title="obj.add2(2,3) reply">r x01 x00 I x00 x00 x00 x05 z</example><s2 title="Object Naming (non-normative)"><p>URLs are flexibleenough to encode object instances as well as simplestatic service locations. The URL uniquely identifies theHessian object. Thus, Hessian can supportobject-oriented services, e.g. naming services, entity beans, orsession beans, specified by the URL without requiring extra method parametersor headers.</p><p>Object naming may use the query string convention that "?id=XXX"names the object "XXX" in the given service. This convention is recommented,but not required.</p><p>For example, a stock quote service might have afactory interface like http://foo.com/stock and object instanceslike http://foo.com?id=PEET. The factory interface would return validobject references through the factory methods.</p></s2><s2 title="Object naming (non-normative)"><p>As an example, the following format is used for EJB:</p><def>http://hostname/hessian<var>/ejb-name</var>?id=<var>object-id</var></def><p><var>http://hostname/hessian</var> identifies the EJB container.In Resin-EJB, this will refer to the EJB Servlet. "/hessian" is the servlet prefix (url-pattern.) HTTP is just used asan example; Hessian does not require the use of HTTP.</p><p><var>/ejb-name</var>, the path info of the request, identifies the EJB name,specifically the home interface. EJB containers can contain severalentity and session beans, each with its own EJB home. The <var>ejb-name</var>corresponds to the ejb-name in the deployment descriptor.</p><p><var>object-id</var> identifies the specific object. For entity beans, theobject-id encodes the primary key. For session beans, the object-id encodesa unique session identifier. Home interfaces have no ";ejbid=..." portion.</p><example title="Example Entity Home Identifier">http://localhost/hessian/my-entity-bean</example><example title="Example Entity Bean Identifier">http://localhost/hessian/my-entity-bean?ejbid=slytherin</example><example title="Example Session Home Identifier">http://localhost/hessian/my-session-bean</example><example title="Example Session Bean Identifier">http://localhost/hessian/my-session-bean?ejbid=M9Zs1Zm</example></s2><s2 title="Methods and Overloading"><p>Method names must be unique. Two styles of overloading aresupported: overloading by number of argumetns and overloadingby argument types. Overloading is permitted byencoding the argument types in the method names. The types ofthe actual arguments must not be used to select the methods.</p><p>Method names beginning with <var>_hessian_</var> are reserved.</p><p>Servers should accept calls with either the mangled method nameor the unmangled method name. Clients should send the mangled method name.</p><note>See the Java binding for a possible overloading scheme.</note><example>add(int a, int b)</example><results>add_int_int</results><example>add(double a, double b)</example><results>add_double_double</results><example>add(shopping.Cart cart, shopping.Item item)</example><results>add_shopping.Cart_shopping.Item</results></s2><s2 title="Arguments"><p>Arguments immediately follow the method in positional order.Argument values use Hessian's serialization.</p><p>All arguments share references, i.e. the reference liststarts with the first argument and continues for all other arguments.This lets two arguments share values.</p><example title="remote.eq(bean, bean)">bean = new qa.Bean("foo", 13);System.out.println(remote.eq(bean, bean));</example><results>c x01 x00 m x00 x02 eq M t x00 x07 qa.Bean S x00 x03 foo I x00 x00 x00 x0d z R x00 x00 x00 x00 z</results><p>The number and type of arguments are fixed by the remote method.Variable length arguments are forbidden. Implementationsmay take advantage of the expected type to improve performance.</p></s2><s2 title="Headers"><p>Headers are (string, object) pairs that preceed the arguments.</p><p>The value of the header can be any serialized object.</p><p>For example, a request might include a transaction context in aheader.</p><results title="Call with Distributed Transaction Context">c x01 x00 H x00 x0b transaction r t x00 x28 com.caucho.hessian.xa.TransactionManager S x00 x23 http://hostname/xa?ejbid=01b8e19a77 m x00 x05 debug I x00 x03 x01 xcb z</results></s2><s2 title="Versioning"><p>The call and response tags include a major and minor byte. Thecurrent version is 1.0.</p></s2></s1><s1 title="Reply"><def>valid-reply ::= r x01 x00 <var>header</var>* <var>object</var> zfault-reply ::= r x01 x00 <var>header</var>* <var>fault</var> z</def><s2 title="Value"> <p>A successful reply returns a single value and possiblysome header information. </p> <example title="integer 5 result">r x01 x00 I x00 x00 x00 x05 z</example></s2><s2 title="Faults"><p>Failed calls return a <var>fault</var>.</p><p>Each fault has a number of informative fields, expressed like<map> entries. The defined fields are <var>code</var>, <var>message</var>,and <var>detail</var>. <var>code</var> is one of a short list of stringsdefined below. <var>message</var> is a user-readable message.<var>detail</var> is an object representing the exception. In Java,<var>detail</var> will be a serialized exception.</p><results title="Remote Call throws FileNotFoundException">r x01 x00 f S x00 x04 code S x00 x10 ServiceException S x00 x07 message S x00 x0e File Not Found S x00 x06 detail M t x00 x1d java.io.FileNotFoundException z z</results><deftable><tr><td>ProtocolException</td><td>The Hessian request has some sort ofsyntactic error.</td></tr><tr><td>NoSuchObjectException</td><td>The requested object does not exist.</td></tr><tr><td>NoSuchMethodException</td><td>The requested method does not exist.</td></tr><tr><td>RequireHeaderException</td><td>A required header was not understoodby the server.</td></tr><tr><td>ServiceException</td><td>The called method threw an exception.</td></tr></deftable></s2></s1><s1 title="Metadata (non-normative)"><p>Metadata is handled by special method calls, methods beginningwith <var>_hessian_</var>.</p><p><var>_hessian_getAttribute(String key)</var> returns a string.The following attributes are predefined by this spec:</p><deftable><tr><th>attribute</th><th>meaning</th></tr><tr><td>java.api.class</td><td>Java interface for this URL</td></tr><tr><td>java.home.class</td><td>Java interface for this service</td></tr><tr><td>java.object.class</td><td>Java interface for a service object</td></tr><tr><td>java.ejb.primary.key.class</td><td>Java EJB primary key class</td></tr></deftable><p>"java.api.class" returns the client proxy's Java API classfor the current URL. "java.home.class" returns the API class for thefactory URL, i.e. without any "?id=XXX" query string. "java.object.class"returns the API class for object instances.</p><p>In the case of services with no object instances, i.e.non-factory services, all three attributes will return thesame class name.</p><s2 title="Obsolete meta data properties"><deftable><tr><th>attribute</th><th>meaning</th></tr><tr><td>home-class</td><td>Java class for the home interface.</td></tr><tr><td>remote-class</td><td>Java class for the object interface.</td></tr><tr><td>primary-key-class</td><td>Java class for the primary key.</td></tr></deftable></s2></s1><s1 title="Micro Hessian"><p>A "Micro Hessian" implementation may omit support for the "double" type.</p></s1><s1 title="Formal Definitions"><def><var>top</var> ::= <var>call</var> ::= <var>reply</var><var>call</var> ::= c x01 x00 <var>header</var>* <var>method</var> <var>object</var>* z<var>reply</var> ::= r x01 x00 <var>header</var>* <var>object</var> z ::= r x01 x00 <var>header</var>* <var>fault</var> z<var>object</var> ::= <var>null</var> ::= <var>boolean</var> ::= <var>int</var> ::= <var>long</var> ::= <var>double</var> ::= <var>date</var> ::= <var>string</var> ::= <var>xml</var> ::= <var>binary</var> ::= <var>remote</var> ::= <var>ref</var> ::= <var>list</var> ::= <var>map</var><var>header</var> ::= H b16 b8 header-string <var>object</var><var>method</var> ::= m b16 b8 method-string<var>fault</var> ::= f (<var>object</var> <var>object</var>)* z<var>list</var> ::= V <var>type</var>? <var>length</var>? <var>object</var>* z<var>map</var> ::= M <var>type</var>? (<var>object</var> <var>object</var>)* z<var>remote</var> ::= r <var>type</var>? <var>string</var><var>type</var> ::= t b16 b8 type-string<var>length</var> ::= l b32 b24 b16 b8<var>null</var> ::= N<var>boolean</var> ::= T ::= F<var>int</var> ::= I b32 b24 b16 b8<var>long</var> ::= L b64 b56 b48 b40 b32 b24 b16 b8<var>double</var> ::= D b64 b56 b48 b40 b32 b24 b16 b8<var>date</var> ::= d b64 b56 b48 b40 b32 b24 b16 b8<var>string</var> ::= (s b16 b8 string-data)* S b16 b8 string-data<var>xml</var> ::= (x b16 b8 xml-data)* X b16 b8 xml-data<var>binary</var> ::= (b b16 b8 binary-data)* B b16 b8 binary-data<var>ref</var> ::= R b32 b24 b16 b8</def></s1><s1 title="Copyright and Licensing"><p>© Copyright 2000-2004 Caucho Technology, Inc. All Rights Reserved.</p><p>Any party may implement this protocol for any purpose without royaltyor license fee, provided that the implementation conforms to thisspecification. Caucho Technology reserves the right to create atest suite, freely available without royalty or license fee, tovalidate implementation conformance. The limited permissions grantedherein are perpetual and may not be revoked by Caucho Technology orits successors or assigns.</p><p>This document and translations of it may be copied and furnished toothers, and derivative works that comment on or otherwise explain itor assist in its implementation may be prepared, copied, published anddistributed, in whole or in part, without restriction of any kind,provided that the above copyright notice and these paragraphs areincluded on all such copies and derivative works.</p><p>This document and the information contained herein is provided on an"AS IS" basis and CAUCHO TECHNOLOGY DISCLAIMS ALL WARRANTIES, EXPRESSOR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OFTHE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIEDWARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.</p></s1><s1 title="Changes"><s2 title="changes in 1.0.2"><ul><li>Clarified that length of XML and strings is in characters (Petr Gladkikh)</li></ul></s2><s2 title="changes in 1.0"><ul><li>Removed unidirectional messages.</li></ul></s2><s2 title="changes in V3"><ul><li>Added unidirectional messages</li><li>Removed 'v' from reply</li><li>changed length code to 'l'</li><li>made <var>type</var> and <var>length</var> optional</li></ul></s2><s2 title="changes in V2"><ul><li>EJB naming: clarified examples especially for session beans (John Mitchell)</li><li>Formal definitions: clarified grammar and added missing object (John Mitchell)</li><li>Formal definitions: initial binary should use 'b' (John Mitchell)</li></ul></s2></s1></body></document>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -