How to Integrate HessianPHP with Diggmore Action

Hessian是Caucho的一个Web Service协议, 使用二进制数据传输. 相比SOAP来更加简单, 而且速度更快. 目前该协议有多种语言的实现, 如java, .net, ruby等等. 而HessianPHP是hessian的PHP的实现.

Diggmore是PHPMore在Zend Framework基础上所做的一个框架性应用. Action是Diggmore中的基本执行单元. 执行的时候会by Name的Autoware. 下面是一个简单的范例.

code 1 HessianResultType
require_once(dirname(__FILE__).”/ResultType.php”);
require_once(dirname(__FILE__).”/../3rd/hessianphp/HessianService.php”);

/**
* @package DiggMore
* @subpackage Core
* @copyright Copyright (c) 2006 PHP More. (http://www.phpmore.com/)
* @author Binzy Wu
*/
class HessianResultType implements ResultType
{
/**
*
* @see ResultType::process
*
*/
public function process($result, Action $action, $controller = null)
{
$wrapper = new HessianService();

$action_config = $action->getConfig();
$resource = $action_config[$result][’resource’];

$wrapper->registerObject($action->$resource);
$wrapper->displayInfo = true;
$wrapper->service();

}
}

code 2 HessianAction

require_once(dirname(__FILE__).”/../../lib/core/ActionSupport.php”);

class HessianUserService
{

private $userService;

public function HessianUserService($userService)
{
//
$this->userService = $userService;
}

public function register($user)
{
// do validate
if ($this->validate_input($user))
{
$this->userService->addUser($user);

}
else
{
return false;
}

}

public function update($user)
{
//…
}

public function validate($username, $password)
{
//…
}

public function getinfo($userid)
{
//…
}

private function validate_input($user)
{
//…
}
}

class User_HessianAction extends ActionSupport
{

public $userService;

public $serviceObject;

public function execute()
{
$this->config = array(
“success”=>array(”type”=>”hessian”, “resource”=>”serviceObject”),
);
//
$this->serviceObject = new HessianUserService($this->userService);
return “success”;
}
}

Related Posts

One Response to “How to Integrate HessianPHP with Diggmore Action”

Leave a Reply