今天听同事说hessian也可以以http的方式和其他的语言交换数据,一直用soap,看来是孤陋寡闻了。
一、hessian是什么?
复制代码 代码如下:
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();
?>
复制代码 代码如下:
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);
}
?>