Menu

Tree [r5] /
 History

HTTPS access


File Date Author Commit
 PHPTest.php 2009-08-19 gaoquanwang [r3]
 Readme.txt 2009-08-19 gaoquanwang [r3]
 db_svc.erl 2009-08-19 gaoquanwang [r3]
 echo_svc.erl 2009-08-19 gaoquanwang [r3]
 hessian.erl 2009-11-10 gaoquanwang [r5]
 test.erl 2009-08-19 gaoquanwang [r3]

Read Me

			Hessian 1.0.2 implemention for Erlang

1. How to run test sample?
	To run test sample, you need mochiweb.
	
	Then Compile code, and run erl command, then type test:start() to start hessian server.
	To demonstrate client, type test:client(), the process and result will shown on console.
	For hessian client, you can choose other implementions, such as HessianPHP.

2. How to write a service?
	In source code directory, only hessian.erl is core module, others just for test.
echo_svc.erl and db_svc.erl are two service module which function can be called from remote 
by hessian client. test.erl first initalize hessian, and register service modules and records, 
and then run mochiweb as web server to receive request call, in request process function, 
just call hessian:dispatch, then response the result to client.

hessian service module implements as a elrang behaviour, similar to gen_server, which
must export two callback function: 
	hessian_init(Arg) -> {ok, Url, State}
		when client requests this Url, it will map to this module,
		and State value will be pass to hessian_call subsequently.
	hessian_close(State)
		called when hessian stop.
	hessian_call(Method, Args, State) -> {reply, Result}


3. hessian module description
	start_link() -> {ok, Pid}
	start() -> {ok, Pid}
		initialize hessian library

	register_module(Module, Arg)
	register_modules(Modules)
		register hessian service module to hessian to work,
		Arg pass to hessian_init.

	register_record(ExternName, Fields, DefValue)
		register a record to hessian, which provide a function to map a object to
		erlang record.
		ExternName is the external class name, 
		Fields is the record field names(acquired from	record_info(fields, recordname)),
		DefValue is the record default value, commonly assigned #recordname{}.

	dispatch(Url, Bin) -> binary()
	dispatch(Url, Bin, LogFun) -> binary()
		this function is called by hessian server to dispatch request to service module.
		Url is the client request url, by this url to find corresponding module.
		Bin is request data, encoded by hessian format.
		return binary also encoded by hessian format.

	call(Method, Args, SendFun)
	call(Method, Args, Url)
		this function provides for hessian client.
		Args is argument list.
		SendFun is a function to send http request(see example test:client()).
		return the remote response data, already decode as erlang value.

PS:
	hessian ref and remote data type are not implemented.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.