zend_xmlrpc مشكلة المعلمة
-
21-09-2019 - |
سؤال
أحاول الحصول على إعداد خادم XMLRPC عميل/خادم بسيط ، لكنني أواجه مشكلة في استخدام المعلمات. يعمل الرمز بشكل جيد إذا أخذت $ client_id المعلمة من FetchClient () طريقة و $ client-> call (). ومع ذلك ، إذا قمت بتضمينه ، فإن الخادم يعود "لا تتطابق معلمات الاتصال"
رمز وحدة التحكم:
class XmlrpcController extends Zend_Controller_Action
{
public function init()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
}
public function indexAction()
{
$server = new Zend_XmlRpc_Server();
$server->setClass('App_Service_Customer','customer');
echo $server->handle();
}
}
التطبيق/الخدمة/customer.php:
class App_Service_Customer
{
/**
* @param int $client_id
* @return string
*/
public function fetchCustomer($client_id)
{
return 'john doe';
}
}
رمز اختبار العميل:
$client = new Zend_XmlRpc_Client('http://localhost/xmlrpc');
echo $client->call('customer.fetchCustomer', 1);
أيه أفكار؟
المحلول
تجاهل. لقد اكتشفت المعلمة الصحيحة للإدخال:
echo $client->call('customer.fetchCustomer', array(array('client_id' => 1)));
لا تنتمي إلى StackOverflow