我在尝试使用官方文档在Zend Framework 2下实现JSON-RPC服务器时遇到了一些问题
我已经在我的application/model/caculator.php下创建了计算器类但在应用程序/controller/indexController.php中,我无法处理服务器请求:
public function indexAction(){
$server = new 'Zend'Json'Server'Server();
// Indicate what functionality is available:
$server->setClass('Application'Model'Calculator');
// Handle the request:
$server->handle();
$view = new ViewModel();
return $view;
}
并得到以下错误:
{"error":{"code":-32600,"message":"Invalid Request","data":null},"id":null}
不用说,我在网络上还没有找到任何将JSON-RPC实现为zendframework2的好教程。
我使用了zf1,并考虑使用zf2。
唯一的建议是检查请求,也许你不使用命名的参数。不管怎样,只要调试zf2源代码就可以了。