我试图得到一个简单的客户端/服务器XML-RPC服务器的设置,但我在使用参数的麻烦。代码运行很好,如果我采取的 $ CLIENT_ID 参数出的 fetchClient()方式的和 $客户机 - >呼叫()即可。但是,如果我有它,服务器返回“调用参数不匹配的签名

控制器代码:

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)));
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top