urlstr = $urlstr; } function execute($func, $args) { $ctx = stream_context_create(array('http' => array( 'method' => 'POST', 'header' => 'Content-Type: text/xml', 'content' => xmlrpc_encode_request($func, $args) ))); return xmlrpc_decode(file_get_contents($this->urlstr, false, $ctx)); } } function data2string($o) { return '(' . $o['ival'] . ',' . $o['sval'] . ')'; } function test($urlstr) { echo "$urlstr\r\n"; $cli = new Client($urlstr); $v = $cli->execute('Test.getInt', array()); echo $v . "\r\n"; $s = $cli->execute('Test.getString', array()); echo $s . "\r\n"; $d = $cli->execute('Test.getData', array()); echo data2string($d) . "\r\n"; $lst = $cli->execute('Test.getListOfInts', array()); echo '[' . implode(',', $lst) . ']' . "\r\n"; $lst = $cli->execute('Test.getListOfStrings', array()); echo '[' . implode(',', $lst) . ']' . "\r\n"; $lst = $cli->execute('Test.getListOfData', array()); echo '[' . implode(',', array_map(function($elm) { return data2string($elm); }, $lst)) . ']' . "\r\n"; $v1 = 123; $v2 = 456; $v3 = $cli->execute('Test.add', array($v1, $v2)); echo $v3 . "\r\n"; $s1 = 'ABC'; $s2 = 'DEF'; $s3 = $cli->execute('Test.concat', array($s1, $s2)); echo $s3 . "\r\n"; $d = array('ival' => 123, 'sval' => 'ABC'); $d2 = $cli->execute('Test.modify', array($d)); echo data2string($d2) . "\r\n"; } test('http://localhost:8001/'); test('http://localhost:8002/'); ?>