程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> php hessian詳細介紹

php hessian詳細介紹

編輯:關於PHP編程

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();
?>

服務器端結果

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結果

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved