首先到官网(http://www.phprpc.org/zh_CN/ )上面去下载最新版的phprpc,解压之后会有相关的文件,我们把文件进行划分(服务端和客户端文件)如下:
服务端文件:dhparams
dhparams.php
phprpc_server.php
bigint.php
compat.php
phprpc_date.php
xxtea.php 客户端文件:phprpc_client.php
bigint.php
compat.php
phprpc_date.php
xxtea.php 我们把服务端文件放在服务端文件夹中,然后把客户端文件放在客户端文件夹中,之后再服务端文件夹中新建个文件(server.php)作为服务,然后再客户端新建个文件(client.php)作为客户端,各自代码如下:
server端:[code]<?php
include_once"phprpc_server.php"; //加载phprpc文件
$server = new PHPRPC_Server();
$server->add(‘getUser’);
$server->setDebugMode(true);
$server->start();
function getUser( )
{
return ‘the data you request!’;
}
client端:
[code]
<?php include_once "phprpc_client.php"; $client = new PHPRPC_Client('http://127.0.0.1/phpservice/phprpcserver/server.php'); $data = $client->getUser(); var_dump($data); //得到:the data you request! [/code]这上面提到wsdl之后会讲到如何生成。