Home > Backend Development > PHP Tutorial > Introduction to the use of hessian in PHP_PHP tutorial

Introduction to the use of hessian in PHP_PHP tutorial

WBOY
Release: 2016-07-21 15:33:36
Original
867 people have browsed it

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
Introduction to the use of hessian in PHP_PHP tutorial
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.

www.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...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template