一、hessian是什么?
看到這個單詞我還不知道怎么讀,音標是[hes]讀黑森。
Hessian是一個輕量級的遠程的數據交換工具,使用簡單的方法提供了RMI(遠程方法調用)的功能. 相比WebService,Hessian更簡單、快捷。采用的是二進制RPC協議,因為采用的是二進制協議,所以它很適合于發送二進制數據
hessian是獨立于語言的。
二、在PHP中怎么用的呢?
你是不是認為這個和soap一樣在php.ini中開啟一個就可以使用了,我也這么認為的。可
是我要告訴你的是這樣的想法是錯誤的。
需要去下載一個HessianPHP的庫來使用。下載地址http://hessianphp.sourceforge.net/
三、看看怎么使用。
1、服務器端。<?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();
?>
服務器端結果
@D58XA@(R1KB8S3_18Q0BJ2
2、客戶端<?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結果
8