今天听同事说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();
?>
服务器端结果
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
呵呵!看来试用成功了。
四、要注意的一些问题。
发现有个朋友使用的时候碰到的问题总结贴,很不错。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
