首页 > 代码库 > phprpc远程调用报错,不知道什么原因
phprpc远程调用报错,不知道什么原因
我在学习phprpc远程调用,按照网上的教程,发现报错:Incorrect response id (request id: 1, response id: ) n;好纠结啊,求教。贴出代码如下:
服务端,member.php
<?php
require_once ‘jsonRPCServer.php‘;
/**
User: Administrator
Date: 2015/12/28
Time: 11:06
*/
class member
{
public function getName()
{ return ‘hello word ‘; // 返回字符串}
}
// 服务端调用
$myExample = new member();
// 注入实例
jsonRPCServer::handle($myExample) or print ‘no request‘;
客户端:client.php
<?php
/**
User: Administrator
Date: 2015/12/28
Time: 11:07*/require_once ‘jsonRPCClient.php‘;//$url = ‘http://localhost/phprpc/server.php‘;$url = ‘http://localhost/phprpc/member.php‘;$myExample = new jsonRPCClient($url);echo ‘‘;print_r($myExample);// 客户端调用
try
{
$name = $myExample->getName();
echo $name;
} catch (Exception $e)
{
echo nl2br($e->getMessage()) . ‘
‘ . "n";
}
phprpc远程调用报错,不知道什么原因