protected function _callService($method, $class = 'ZendTest\\AMF\\TestAsset\\testclass') { $request = new \Zend\AMF\Request\StreamRequest(); $request->setObjectEncoding(0x3); $this->_server->setClass($class); $newBody = new \Zend\AMF\Value\MessageBody("{$class}.{$method}", "/1", array("test")); $request->addAmfBody($newBody); $this->_server->handle($request); $response = $this->_server->getResponse(); return $response; }
protected function _callService($method, $class = 'Zend_Amf_Resource_testclass') { $request = new Zend_Amf_Request(); $request->setObjectEncoding(0x3); $this->_server->setClass($class); $newBody = new Zend_Amf_Value_MessageBody("{$class}.{$method}", "/1", array("test")); $request->addAmfBody($newBody); $this->_server->handle($request); $response = $this->_server->getResponse(); return $response; }
public function testLogout() { Zend_Session::$_unitTestEnabled = true; $this->_server->setAuth(new RightPassword("testuser", "testrole")); $this->_acl->addRole(new Zend_Acl_Role("testrole")); $this->_acl->allow("testrole", null, null); $this->_server->setAcl($this->_acl); $resp = $this->_callServiceAuth("testuser", ""); $this->assertTrue($resp[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage); $this->assertContains("hello", $resp[1]->getData()); // After logout same request should not be allowed $this->setUp(); $this->_server->setAuth(new RightPassword("testuser", "testrole")); $this->_server->setAcl($this->_acl); $request = new Zend_Amf_Request(); $request->setObjectEncoding(0x3); $this->_addLogout($request); $this->_addServiceCall($request); $this->_server->handle($request); $resp = $this->_server->getResponse()->getAmfBodies(); $this->assertTrue($resp[0]->getData() instanceof Zend_Amf_Value_Messaging_AcknowledgeMessage); $data = $resp[1]->getData(); $this->assertTrue($data instanceof Zend_Amf_Value_Messaging_ErrorMessage); $this->assertContains("not allowed", $data->faultString); }
public function index() { // Require Zend_Amf_Server require_once 'Zend/Amf/Server.php'; // *ZAMFBROWSER IMPLEMENTATION* // Require the ZendAmfServiceBrowser class, required to retrieve the list of methods on the ZendAMF server. require_once Kohana::find_file('vendor/ZamfBrowser', 'ZendAmfServiceBrowser'); // Start Server $server = new Zend_Amf_Server(); // $server->addDirectory( SHAREDPATH.Kohana::config('zendamf.services_path') ); $services_path = APPPATH . Kohana::config('zendamf.services_path'); $files = Kohana::list_files($services_path, FALSE); foreach ($files as $file) { $class = pathinfo($file, PATHINFO_FILENAME); $server->setClass($class); } // // do class mapping $vo_path = APPPATH . Kohana::config('zendamf.vo_path'); $files = Kohana::list_files($vo_path, FALSE); foreach ($files as $file) { $class = pathinfo($file, PATHINFO_FILENAME); $server->setClassMap($class, $class); } // *ZAMFBROWSER IMPLEMENTATION* // Add the ZendAmfServiceBrowser class to the list of available classes. $server->setClass("ZendAmfServiceBrowser"); // *ZAMFBROWSER IMPLEMENTATION* // Set this reference the class requires to the server object. // ZendAmfServiceBrowser::setAmfServer( $server ); ZendAmfServiceBrowser::$ZEND_AMF_SERVER = $server; // Handle the AMF request echo $server->handle(); }
/** +---------------------------------------------------------- * 应用程序初始化 +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @return void +---------------------------------------------------------- */ public static function run() { // 设定错误和异常处理 set_error_handler(array('App', "appError")); set_exception_handler(array('App', "appException")); //[RUNTIME] // 检查项目是否编译过 // 在部署模式下会自动在第一次执行的时候编译项目 if (defined('RUNTIME_MODEL')) { // 运行模式无需载入项目编译缓存 } elseif (is_file(RUNTIME_PATH . '~app.php') && (!is_file(CONFIG_PATH . 'config.php') || filemtime(RUNTIME_PATH . '~app.php') > filemtime(CONFIG_PATH . 'config.php'))) { // 直接读取编译后的项目文件 C(include RUNTIME_PATH . '~app.php'); } else { // 预编译项目 App::build(); } //[/RUNTIME] //导入类库 Vendor('Zend.Amf.Server'); //实例化AMF $server = new Zend_Amf_Server(); $actions = explode(',', C('APP_AMF_ACTIONS')); foreach ($actions as $action) { $server->setClass($action . 'Action'); } echo $server->handle(); // 保存日志记录 if (C('LOG_RECORD')) { Log::save(); } return; }
public function testLogout() { $this->_server->setAuth(new TestAsset\Authentication\RightPassword("testuser", "testrole")); $this->_acl->addRole(new Role\GenericRole("testrole")); $this->_acl->allow("testrole", null, null); $this->_server->setAcl($this->_acl); $resp = $this->_callServiceAuth("testuser", ""); $this->assertTrue($resp[0]->getData() instanceof Messaging\AcknowledgeMessage); $this->assertContains("hello", $resp[1]->getData()); // After logout same request should not be allowed $this->setUp(); $this->_server->setAuth(new TestAsset\Authentication\RightPassword("testuser", "testrole")); $this->_server->setAcl($this->_acl); $request = new Request\StreamRequest(); $request->setObjectEncoding(0x03); $this->_addLogout($request); $this->_addServiceCall($request); $this->_server->handle($request); $resp = $this->_server->getResponse()->getAmfBodies(); $this->assertTrue($resp[0]->getData() instanceof Messaging\AcknowledgeMessage); $data = $resp[1]->getData(); $this->assertTrue($data instanceof Messaging\ErrorMessage); $this->assertContains("not allowed", $data->faultString); }
public function indexAction() { $this->_helper->viewRenderer->setNoRender(); $server = new Zend_Amf_Server(); $server->addDirectory(APPLICATION_PATH . '/services/'); $server->setProduction(FALSE); echo $server->handle(); }
public function indexAction() { $this->_helper->layout->setLayout('json'); $this->getHelper('ViewRenderer')->setNoRender(); $server = new Zend_Amf_Server(); $server->addDirectory(dirname(__FILE__) . '/../services/'); echo $server->handle(); }
public function amfAction() { $server = new Zend_Amf_Server(); require_once APPLICATION_PATH . '/auth/Auth.php'; $server->setAuth(new Auth()); $server->addDirectory(APPLICATION_PATH . '/services/'); $response = $server->handle(); echo $response; }
/** * PHPRpc控制器架构函数 * @access public */ public function __construct() { //导入类库 think\loader::import('vendor.zend.amf.server'); //实例化AMF $server = new \Zend_Amf_Server(); $server->setClass($this); echo $server->handle(); return; }
public function indexAction() { // action body $server = new Zend_Amf_Server(); $server->setClass('Default_Model_Account'); $server->setClass('Default_Model_Transaction'); $server->setClass('Default_Model_HelloWorld'); $server->setClassMap('AccountVO', 'Default_Model_Vo_Account'); $server->setClassMap('TransactionVO', 'Default_Model_Vo_Transaction'); echo $server->handle(); }
/** +---------------------------------------------------------- * 应用程序初始化 +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @return void +---------------------------------------------------------- */ public static function run() { //导入类库 Vendor('Zend.Amf.Server'); //实例化AMF $server = new Zend_Amf_Server(); $actions = explode(',', C('APP_AMF_ACTIONS')); foreach ($actions as $action) { $server->setClass($action . 'Action'); } echo $server->handle(); // 保存日志记录 if (C('LOG_RECORD')) { Log::save(); } return; }
public function indexAction() { $server = new Zend_Amf_Server(); //set amf server session namespace $server->setSession(Security_Model_Session_Manager::ADMIN_SESSION_NAME); $server->setProduction(false); //set service root directory $server->addDirectory(realpath(dirname(__FILE__) . '/../services/amf/')); //set value object class mapping $server->setClassMap('LoginVO', 'Security_Model_Auth_Vo_LoginVO'); $server->setClassMap('SessionVO', 'Security_Model_Auth_Vo_SessionVO'); echo($server->handle()); }
public function indexAction() { $acl = new Zend_Acl(); $acl->addRole(new Zend_Acl_Role('administrator')); Zend_Session::regenerateId(); $server = new Zend_Amf_Server(); //set amf server session namespace $server->setSession(); $server->setProduction(false); $server->setAcl($acl); //set service root directory $server->addDirectory(realpath(dirname(__FILE__) . '/../services/amf/')); echo($server->handle()); }
/** * Run the AMF server */ public function run() { $enable = $this->get_enable(); if (empty($enable)) { die; } include "Zend/Loader.php"; Zend_Loader::registerAutoload(); //retrieve the api name $classpath = optional_param('classpath', 'user', PARAM_ALPHA); require_once dirname(__FILE__) . '/../../' . $classpath . '/external.php'; /// run the Zend AMF server $server = new Zend_Amf_Server(); $debugmode = get_config($this->get_protocolid(), 'debug'); if (!empty($debugmode)) { $server->setProduction(false); } else { $server->setProduction(true); } $server->setClass($classpath . "_external"); $response = $server->handle(); echo $response; }
public function load() { $folder = 'AmfServices'; defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__))); require_once dirname(__FILE__) . '/../lib/amf/browser/ZendAmfServiceBrowser.php'; set_include_path(dirname(__FILE__) . '/../lib/amf/library' . PATH_SEPARATOR . get_include_path()); require_once dirname(__FILE__) . '/../lib/amf/library/Zend/Amf/Server.php'; $server = new \Zend_Amf_Server(); set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/' . $folder . '/'), get_include_path()))); $service_path = $this->container->getParameter('service_path'); if (empty($service_path)) { $folder = APPLICATION_PATH . '/' . $folder . '/'; } else { $folder = getcwd() . '/../src/' . $service_path . '/Services/AmfServices/'; $folderPath = '/src/' . $service_path . '/Services/AmfServices/'; } if (!is_dir($folder)) { echo 'path is undefined <br /> create: ' . $folderPath; die; } if (count(glob($folder . '*.php')) < 1) { echo 'no services defined'; die; } foreach (glob($folder . '*.php') as $filename) { $service = basename($filename, ".php"); $filerawname = basename($filename); if (file_exists($folder . $filerawname)) { include_once $folder . $filerawname; $server->setClass($service); } } $server->setClass("ZendAmfServiceBrowser"); \ZendAmfServiceBrowser::$ZEND_AMF_SERVER = $server; return $server->handle(); }
<?php define('FANWE_ROOT', str_replace('services/fanwe.php', '', str_replace('\\', '/', __FILE__))); require FANWE_ROOT . 'core/fanwe.php'; @set_include_path(FANWE_ROOT . 'services/'); require "Zend/Amf/Server.php"; require "fanwe.service.php"; $fanwe =& FanweService::instance(); $fanwe->initialize(); $server = new Zend_Amf_Server(); $server->setClass('FanweAmfService'); echo $server->handle();
public function indexAction() { $server = new Zend_Amf_Server(); $server->addDirectory(APPLICATION_PATH . '/services'); echo $server->handle(); }
<?php // Define path to application directory defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application')); // Define application environment defined('APPLICATION_ENV') || define('APPLICATION_ENV', getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'); set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/../library'), get_include_path()))); /** Zend_Application */ require_once 'Zend/Application.php'; // Create application, bootstrap, and run $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini'); $application->bootstrap(); require_once 'Zend/Amf/Server.php'; $server = new Zend_Amf_Server(); $server->addDirectory(dirname(__FILE__) . '/library/Wfw/Services/'); $server->setProduction(FALSE); return $server->handle();
/** * @group ZF-6130 */ public function testServerShouldCastObjectArgumentsToAppropriateType() { $server = new Zend_Amf_Server(); $server->addDirectory(dirname(__FILE__) . '/_files/zf-6130/services'); // Create a mock message $message = new Zend_Amf_Value_Messaging_RemotingMessage(); $message->operation = 'createEmployee'; $message->source = 'EmployeeService'; // original raw request used "destination" $message->body = array(array('office' => 322, 'departmentid' => 3, 'street' => 32, 'zipcode' => 32, 'state' => 32, 'lastname' => 4, 'firstname' => 2, 'photofile' => 322, 'city' => 32, 'id' => 1, 'title' => 4, 'officephone' => 233, 'email' => 32, 'cellphone' => 22)); $body = new Zend_Amf_Value_MessageBody(null, "", $message); $request = new Zend_Amf_Request(); $request->addAmfBody($body); $request->setObjectEncoding(0x3); $response = $server->handle($request); $employee = EmployeeService::$employee; $this->assertNotNull($employee); $this->assertNotEquals(1, $employee->id); $this->assertRegexp('/[a-z0-9]{3,}/', $employee->id); }
<?php set_include_path(get_include_path() . PATH_SEPARATOR . 'C:\\svn\\zend\\ZendFramework-1.10.2-minimal\\library'); require_once 'Zend/Amf/Server.php'; class XCRpcProtocol_AMF { public function getConfiguration($whatever) { } public function beginSession($configuration_blob = null, $login_method = null, $login_blob = null) { $ret = new stdClass(); $ret->session_info = new stdClass(); $ret->session_info->code = "123"; return $ret; } public function login($session_info, $login_method, $login_blob) { $ret = new stdClass(); $ret->session_info = $session_info; $ret->login_method = $login_method; $ret->login_blob = $login_blob; return $ret; } } $server = new Zend_Amf_Server(); $server->setProduction(false); $server->setClass("XCRpcProtocol_AMF"); $response = $server->handle(); echo $response;