【发布时间】:2013-02-19 15:49:17
【问题描述】:
我正在尝试用 PHP 编写简单的 XMLRPC 服务器。
我已经阅读了一些文档,并找到了与此类似的最小实现:
// /xmlrpc.php file
include "lib/xmlrpc.inc";
include "lib/xmlrpcs.inc";
// function that handles example.add XML-RPC method
function add ($xmlrpcmsg)
{
// ???
$sumResult = $a + $b;
// ???
return new xmlrpcresp($some_xmlrpc_val);
}
// creating XML-RPC server object that handles 1 method
$s = new xmlrpc_server(
array(
"example.add" => array("function" => "add")
));
如何创建响应?
假设我想要一个整数 sumResult 的响应,它是通过 XML-RPC 调用传递给 XMLRPC 服务器的 a 和 b 参数的总和。
我正在使用PHP XML-RPC 3.0.0beta(我也可以使用 2.2.2,但我决定使用 3.0.0beta,因为它标记为稳定)。
【问题讨论】: