1. What is hessian?
I don’t know how to pronounce this word when I see it. The phonetic symbol is [hes] pronounced Heisen.
Hessian is a lightweight remote data exchange tool that provides RMI (remote method invocation) function using a simple method. Compared with WebService, Hessian is simpler and faster. The binary RPC protocol is used. Because it is a binary protocol, it is very suitable for sending binary data
hessian is language independent.
2. How to use it in PHP?
Do you think this can be used just like soap by opening one in php.ini? I think so too. But
what I want to tell you is that this idea is wrong.
You need to download a HessianPHP library to use.
Download address http://hessianphp.sourceforge.net/
3. See how to use it.
1. Server side.
Copy code The code is as follows:
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-side result
2. Client
Copy code The code is as follows:
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 the trial was successful.
4. Some issues to pay attention to. I found a friend who posted a summary of the problems he encountered when using it, which is very good.
http://www.bkjia.com/PHPjc/322578.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322578.htmlTechArticle1. What is hessian? When I saw this word, I didn’t know how to pronounce it. The phonetic symbol is [hes] pronounced Heisen. Hessian is a lightweight remote data exchange tool that uses a simple method to provide...