public function batchAction() { $server = new Zend_Rest_Server(); //$test = new Service_Batch(); // $test->getSecurityKey(); $server->setClass('Service_Batch'); $server->handle(); $this->render('index'); }
public function sintegraAction() { // Desabilitar renderização do layout e da view $this->_helper->viewRenderer->setNoRender(true); $this->_helper->layout()->disableLayout(); // Iniciar servidor web service $restSrv = new Zend_Rest_Server(); $restSrv->setClass('AutoLoad_RestServ'); $restSrv->handle(); }
public function mainAction() { /** * Say Hello * * @param string $who * @param string $when * @return string */ require_once 'Zend/Rest/Server.php'; $server = new Zend_Rest_Server(); try { $server->setClass('serviceClass'); } catch (Zend_Exception $e) { echo "Caught exception: " . get_class($e) . "\n"; echo "Message: " . $e->getMessage() . "\n"; } $server->handle(); }
function testHandleReturnObject() { $server = new Zend_Rest_Server(); $server->addFunction('Zend_Rest_Server_TestFunc8'); ob_start(); $server->handle(array('method' => 'Zend_Rest_Server_TestFunc8')); $result = ob_get_clean(); $this->assertEquals("<Zend_Rest_Server_TestFunc8 generator='zend'><foo>bar</foo><baz>1</baz><bat>123</bat><qux>0</qux><status>success</status></Zend_Rest_Server_TestFunc8>", $result, "Bas Response"); }
/** * @group ZF-3751 */ public function testCallingNoMethodDoesNotThrowUnknownButSpecificErrorExceptionMessage() { $server = new Zend_Rest_Server(); $server->setClass('Zend_Rest_Server_Test2'); $server->returnResponse(true); $response = $server->handle(); $this->assertContains('<status>failed</status>', $response); $this->assertNotContains('<message>An unknown error occured. Please try again.</message>', $response); }
<?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') : 'production'); // Ensure library/ is on include_path 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(); // now create the service $server = new Zend_Rest_Server(); $server->setClass('CMS_Api'); $server->handle();
public function testReturnResponseForcesHandleToReturnResponse() { $server = new Zend_Rest_Server(); $server->returnResponse(true); $server->setClass('Zend_Rest_Server_Test2'); ob_start(); $response = $server->handle(array('method' => 'test2Xml')); $result = ob_get_clean(); $this->assertTrue(empty($result)); $this->assertContains('<foo>bar</foo>', $response); }
public function testGeneratedXmlEncodesFaultAmpersands() { $server = new Zend_Rest_Server(); $server->returnResponse(true); $server->setClass('Zend_Rest_Server_Test'); ob_start(); $response = $server->handle(array('method' => 'testExceptionsEncoding')); $result = ob_get_clean(); $this->assertTrue(empty($result)); $this->assertContains('testing class method exception & encoding', $response); }
function createPage($username = NULL, $password = NULL, $id = NULL, $loginToken = NULL, $editToken = NULL, $title = NULL, $text = NULL, $summary = NULL) { $__pcpServer = new PCPServer(); $__userCredentials = new PCPUserCredentials($username, $password, $id, $loginToken, $editToken); print "Testing{$username}, {$password}, {$id}, {$loginToken}, {$editToken}{$title}, {$text}, {$summary}->" . $__pcpServer->createPage($__userCredentials, $title, $text, $summary); print simplexml_load_string(PCPUtil::createXMLResponse($__pcpServer->createPage($__userCredentials, $title, $text, $summary)), 'SimpleXMLElement'); return simplexml_load_string(PCPUtil::createXMLResponse($__pcpServer->createPage($__userCredentials, $title, $text, $summary)), 'SimpleXMLElement'); } function readPage($username = NULL, $password = NULL, $id = NULL, $loginToken = NULL, $editToken = NULL, $title = NULL, $revisionID = NULL) { $__pcpServer = new PCPServer(); $__userCredentials = new PCPUserCredentials($username, $password, $id, $loginToken, $editToken); $_REQUEST = array(); $__pcpServer->login($__userCredentials); // var_dump($__userCredentials,$title, $revisionID); // die; return simplexml_load_string(PCPUtil::createXMLResponse($__pcpServer->readPage($__userCredentials, $title, $revisionID)->toXML()), 'SimpleXMLElement', LIBXML_NOCDATA); } ## # Initialize server and register functions ## if (array_key_exists('action', $_REQUEST) && $_REQUEST['action'] == 'wspcp') { $__wsServer = new Zend_Rest_Server(); $__wsServer->addFunction('login'); $__wsServer->addFunction('logout'); $__wsServer->addFunction('createPage'); $__wsServer->addFunction('readPage'); $__wsServer->handle(); exit; // stop immediately }
/** * @see ZF-1949 */ public function testMissingArgumentsWithDefaultsShouldNotResultInFaultResponse() { $server = new Zend_Rest_Server(); $server->setClass('Zend_Rest_Server_Test'); ob_start(); $server->handle(array('method' => 'testFunc7', 'arg1' => "Davey")); $result = ob_get_clean(); $this->assertContains('<status>success</status>', $result, var_export($result, 1)); $this->assertContains('<response>Hello today, How are you Davey</response>', $result, var_export($result, 1)); }
function __construct() { $server = new Zend_Rest_Server(); $server->setClass('My_Service_Class'); $server->handle(); }
function testHandleVoid() { $server = new Zend_Rest_Server(); $server->addFunction('Zend_Rest_Server_TestFunc10'); ob_start(); $server->handle(array('method' => 'Zend_Rest_Server_TestFunc10')); $result = ob_get_clean(); $this->assertEquals("<Zend_Rest_Server_TestFunc10 generator='zend' version='1.0'><response /><status>success</status></Zend_Rest_Server_TestFunc10>", $result, "Bad Response"); }