Home php教程 php手册 hessian 在PHP中的使用介绍

hessian 在PHP中的使用介绍

Jun 06, 2016 pm 08:35 PM
introduce use

今天听同事说hessian也可以以http的方式和其他的语言交换数据,一直用soap,看来是孤陋寡闻了。

一、hessian是什么?
看到这个单词我还不知道怎么读,美国空间,音标是[hes]读黑森。
Hessian是一个轻量级的远程的数据交换工具,使用简单的方法提供了RMI(远程方法调用)的功能. 相比WebService,香港服务器,Hessian更简单、快捷。采用的是二进制RPC协议,因为采用的是二进制协议,网站空间,所以它很适合于发送二进制数据
hessian是独立于语言的。
二、在PHP中怎么用的呢?
你是不是认为这个和soap一样在php.ini中开启一个就可以使用了,我也这么认为的。可
是我要告诉你的是这样的想法是错误的。
需要去下载一个HessianPHP的库来使用。
下载地址
三、看看怎么使用。
1、服务器端。

复制代码 代码如下:


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


服务器端结果

hessian 在PHP中的使用介绍


2、客户端

复制代码 代码如下:


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

呵呵!看来试用成功了。

四、要注意的一些问题。
发现有个朋友使用的时候碰到的问题总结贴,很不错。
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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use mdf and mds files How to use mdf and mds files Feb 19, 2024 pm 05:36 PM

How to use mdf and mds files

What software is crystaldiskmark? -How to use crystaldiskmark? What software is crystaldiskmark? -How to use crystaldiskmark? Mar 18, 2024 pm 02:58 PM

What software is crystaldiskmark? -How to use crystaldiskmark?

How to download foobar2000? -How to use foobar2000 How to download foobar2000? -How to use foobar2000 Mar 18, 2024 am 10:58 AM

How to download foobar2000? -How to use foobar2000

How to use Baidu Netdisk app How to use Baidu Netdisk app Mar 27, 2024 pm 06:46 PM

How to use Baidu Netdisk app

How to use Xiaoai Speaker How to connect Xiaoai Speaker to mobile phone How to use Xiaoai Speaker How to connect Xiaoai Speaker to mobile phone Feb 22, 2024 pm 05:19 PM

How to use Xiaoai Speaker How to connect Xiaoai Speaker to mobile phone

How to use NetEase Mailbox Master How to use NetEase Mailbox Master Mar 27, 2024 pm 05:32 PM

How to use NetEase Mailbox Master

BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange? BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange? Apr 26, 2024 am 09:40 AM

BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange?

Teach you how to use the new advanced features of iOS 17.4 'Stolen Device Protection' Teach you how to use the new advanced features of iOS 17.4 'Stolen Device Protection' Mar 10, 2024 pm 04:34 PM

Teach you how to use the new advanced features of iOS 17.4 'Stolen Device Protection'

See all articles