本文整理汇总了PHP中Zend_Amf_Request::addAmfBody方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Amf_Request::addAmfBody方法的具体用法?PHP Zend_Amf_Request::addAmfBody怎么用?PHP Zend_Amf_Request::addAmfBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Amf_Request
的用法示例。
在下文中一共展示了Zend_Amf_Request::addAmfBody方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _callService
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;
}
示例2: testPHPNullSerializedToAmf0Null
public function testPHPNullSerializedToAmf0Null()
{
$data = null;
$newBody = new Zend_Amf_Value_MessageBody('/1/onResult', null, $data);
$this->_response->setObjectEncoding(0x0);
$this->_response->addAmfBody($newBody);
$this->_response->finalize();
$testResponse = $this->_response->getResponse();
// Load the expected response.
$mockResponse = file_get_contents(dirname(__FILE__) . '/Response/mock/nullAmf0Response.bin');
// Check that the response matches the expected serialized value
$this->assertEquals($mockResponse, $testResponse);
}
示例3: testCtorExcection
public function testCtorExcection()
{
$this->_server->setClass('Zend_Amf_testException');
$this->_server->setProduction(false);
$message = new Zend_Amf_Value_Messaging_RemotingMessage();
$message->operation = 'hello';
$message->source = 'Zend_Amf_testException';
$message->body = array("123");
// create a mock message body to place th remoting message inside
$newBody = new Zend_Amf_Value_MessageBody(null, "/1", $message);
$request = new Zend_Amf_Request();
// at the requested service to a request
$request->addAmfBody($newBody);
$request->setObjectEncoding(0x3);
// let the server handle mock request
$this->_server->handle($request);
$response = $this->_server->getResponse()->getAMFBodies();
$this->assertTrue($response[0]->getData() instanceof Zend_Amf_Value_Messaging_ErrorMessage);
$this->assertContains("Oops, exception!", $response[0]->getData()->faultString);
}
示例4: testServerShouldCastObjectArgumentsToAppropriateType
/**
* @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);
}
示例5: getAMFResponse
/**
* Handles passing a request through the amf client
* @param {string} $servicePath Service path i.e ServerController.connect
* @param {object|array} $data Data to be sent with the request should be an array or an object
* @return {array} Server response
*/
protected function getAMFResponse($servicePath, $data = null)
{
require_once 'Zend/Amf/Request.php';
require_once 'Zend/Amf/Constants.php';
require_once 'Zend/Amf/Value/MessageBody.php';
require_once 'Zend/Amf/Value/Messaging/RemotingMessage.php';
require_once 'Zend/Amf/Value/Messaging/ErrorMessage.php';
if ($data) {
if (is_array($data)) {
$data = $this->arrayToObject($data);
} else {
if (!is_object($data)) {
user_error('$data is not an array or object', E_USER_ERROR);
}
}
}
//Find the method and service
$service = explode('.', $servicePath);
$method = array_pop($service);
$service = implode('.', $service);
//Build the message
$message = new Zend_Amf_Value_Messaging_RemotingMessage();
$message->parameters = $data;
$message->operation = $method;
$message->source = $service;
//Build the message body
$body = new Zend_Amf_Value_MessageBody($servicePath, '/1', array($data));
//Build the AMF Request
$request = new Zend_Amf_Request();
$request->addAmfBody($body);
$request->setObjectEncoding(Zend_Amf_Constants::AMF3_OBJECT_ENCODING);
//Init the client api
$amfClient = new CodeBank_ClientAPI();
$amfClient->setTestRequest($request);
//Capture the response as an amf input stream
ob_start();
$response = $amfClient->index();
ob_end_clean();
//Get the amf bodies
$bodies = $response->getAmfBodies();
if (count($bodies) > 0) {
$body = $bodies[0]->getData();
if ($body instanceof Zend_Amf_Value_Messaging_ErrorMessage) {
$this->fail('AMF Server returned an error: ' . $body->faultString . "\n\n" . $body->faultDetail);
return false;
}
return $body;
}
return false;
}