1. What is hessian?
I still don't know how to read this word. The phonetic alphabet is [hes.
Hessian is a lightweight remote data exchange tool that provides the RMI (remote method call) function in a simple way. Hessian is simpler and faster than WebService. Binary RPC is used. Because binary is used, it is suitable for sending binary data.
Hessian is language independent.
2. How to use it in PHP?
Do you think this is the same as soap and can be used by enabling one in php. ini? I think so too. Yes
What I want to tell you is that this idea is wrong.
Download a HessianPHP library.
Http://hessianphp.sourceforge.net/
3. Check how to use it.
1. server side.
Copy codeThe Code is as follows:
<? Php
Include_once ('hessianphp/dist/HessianService. php ');
Class HelloWorldService
{
Public function _ construct ()
{
}
Public function add ($ a, $ B)
{
Return $ a + $ B;
}
}
$ Wrapper = new HessianService ();
$ Wrapper-> registerObject (new HelloWorldService );
$ Wrapper-> displayInfo = true;
$ Wrapper-> service ();
?>
Server result
2. Client
Copy codeThe Code is as follows:
<? Php
Require_once 'hessianphp/dist/HessianClient. php ';
Hessian: errorReporting (HESSIAN_SILENT );
$ Url = 'HTTP: // localhost/info. php ';
$ Proxy = & new HessianClient ($ url );
$ Sum = $ proxy-> add (3, 5 );
Echo $ sum;
If (Hessian: error ()){
$ Errors = Hessian: error ();
Print_r ($ erros-> message );
// Var_dump ($ errors );
}
?>
Client result
8
Haha! It seems that the trial is successful.
4. Notes.
I found that the problem I encountered when I used it was very good.