RPC Proxy support hessian 2.0 protocol, with fully tested via test service in http://hessian.caucho.com/test/test2
I couldn't not find a stable hessian 1.0 protocol test service. so 1.0 is not fully implmented yet.
npm install hessian-proxy
var Proxy = require'hessian-proxy'Proxy;var proxy = '' username password proxy;proxyinvokemethodName arg1 arg2 arg3// ... do with reply;// use writer2var Writer = require'hessian-proxy'Writer2; // for hessian2.0var writer = ;writerwriteCallmethod arg1 arg2…;var buffer = writergetBuffer;// use reader2var Reader = require'hessian-proxy'Reader2; // for hessian2.0var reader = ;var data = readerreadRPCMessagebuffergetData;
Binary will be represented by Buffer in node js.
true or false
Represented as Date type.
Just as normal int.
Arrays will be sent as list, typed list need to add a property 'type' to the array. Typed List will have type in 'type' property.
// untyped listvar list = 123;// typed listvar list = 'a' 'b' 'c';list__type__ = '[string';
use Long.js to handle long value.
var Long = require'long';var long = low high;// orvar long = low: lowbit high: highbit ;
If you don't care about key type, all the keys will be string. the normal Object will be treated as a map. If you want to parse/send maps that use objects as key. You have to expose a ES6 standard Map Class to global namespace.
And typed Map will have type in 'mapType' property.
globalMap = require'es6-map-shim'Map;
// normal untyped map, all the key will be stringvar map =1: 1'a': 0'b': 2;// normal typed mapvar map ='a': 0'b': 1;map__mapType__ = 'java.util.Hashtable';// es6 Map, object can be used as keyvar map = ;mapset'a' 0;mapset'b' 1;mapsettrue 'true';// add typemap__mapType__ = 'java.util.Hashtable';
The proxy will take the job for you if the objects are equal via strict equal '===='.
To send Object, objects must have a type in 'type' property. Otherwise, it will be send as a map.
var obj ='value': 0'next': 1;obj__type__ = 'com.test.TestObject';
Just as null.
For webservice support call, reply, fault. packet+ and envelope+ current are not supported yet.
Notice: There are some mistakes in the document and make a lot of confuse when writing protocol according to spec, especially when doing test and just find test docs are not correct for some arguments values.
(The BSD License)
Copyright (c) 2013, Villa.Gao <email@example.com>; All rights reserved.