Hi I am trying to integrate the xmlrpc server into a class, does anyone
know how to get it working?
test.html:
<html>
<head>
<title>XMLRPC Test</title>
<script src="jsolait/init.js"></script>
<script src="jsolait/lib/urllib.js"></script>
<script src="jsolait/lib/xml.js"></script>
<script src="jsolait/lib/xmlrpc.js"></script>
<script>
var xmlrpc=null;
try{
var xmlrpc = importModule("x mlrpc");
}catch(e){
throw "importing of xmlrpc module failed.";
}
doSome = function()
{
try{
var service = new
xmlrpc.ServiceP roxy("http://localhost/test.php");
var something = service.Server. display();
alert(something );
}catch(e){
alert("nothing" );
}
}
</script>
</head>
<body bgcolor="#D4D0C 8">
<a href="javascrip t:doSome()">cli ck</a>
</body>
</script>
</html>
-----------------------------------------------------------------------------------------
and test.php side:
<?php
include 'xmlrpc/xmlrpc.inc';
include 'xmlrpc/xmlrpcs.inc';
class Server
{
function Server()
{
}
function sumAndDifferenc e ($params) {
$xval = $params->getParam(0);
$x = $xval->scalarval();
$yval = $params->getParam(1);
$y = $yval->scalarval();
// Build our response.
$struct = array('sum' => new xmlrpcval($x + $y, 'int'),
'difference' => new xmlrpcval($x - $y, 'int'));
return new xmlrpcresp(new xmlrpcval($stru ct, 'struct'));
}
function display()
{
return new xmlrpcresp(new xmlrpcval("Jame s",
'string'));
}
function makeServer()
{
$sumAndDifferen ce_sig = array(array('st ruct', 'int',
'int'));
$sumAndDifferen ce_doc = 'Add and subtract two numbers';
$display_sig = array(array('st ruct'));
$display_doc = 'Add and subtract two numbers';
new xmlrpc_server(a rray('server.su mAndDifference' =>
array('function ' => 'sumAndDifferen ce',
'signature' => $sumAndDifferen ce_sig,
'docstring' => $sumAndDifferen ce_doc),
'display'=>
array('function ' => 'Server.display ',
'signature' => $display_sig,
'docstring' => $display_doc)
));
}
}
$test = new Server();
$server = $test->makeServer() ;
?>
Thanks in advance
know how to get it working?
test.html:
<html>
<head>
<title>XMLRPC Test</title>
<script src="jsolait/init.js"></script>
<script src="jsolait/lib/urllib.js"></script>
<script src="jsolait/lib/xml.js"></script>
<script src="jsolait/lib/xmlrpc.js"></script>
<script>
var xmlrpc=null;
try{
var xmlrpc = importModule("x mlrpc");
}catch(e){
throw "importing of xmlrpc module failed.";
}
doSome = function()
{
try{
var service = new
xmlrpc.ServiceP roxy("http://localhost/test.php");
var something = service.Server. display();
alert(something );
}catch(e){
alert("nothing" );
}
}
</script>
</head>
<body bgcolor="#D4D0C 8">
<a href="javascrip t:doSome()">cli ck</a>
</body>
</script>
</html>
-----------------------------------------------------------------------------------------
and test.php side:
<?php
include 'xmlrpc/xmlrpc.inc';
include 'xmlrpc/xmlrpcs.inc';
class Server
{
function Server()
{
}
function sumAndDifferenc e ($params) {
$xval = $params->getParam(0);
$x = $xval->scalarval();
$yval = $params->getParam(1);
$y = $yval->scalarval();
// Build our response.
$struct = array('sum' => new xmlrpcval($x + $y, 'int'),
'difference' => new xmlrpcval($x - $y, 'int'));
return new xmlrpcresp(new xmlrpcval($stru ct, 'struct'));
}
function display()
{
return new xmlrpcresp(new xmlrpcval("Jame s",
'string'));
}
function makeServer()
{
$sumAndDifferen ce_sig = array(array('st ruct', 'int',
'int'));
$sumAndDifferen ce_doc = 'Add and subtract two numbers';
$display_sig = array(array('st ruct'));
$display_doc = 'Add and subtract two numbers';
new xmlrpc_server(a rray('server.su mAndDifference' =>
array('function ' => 'sumAndDifferen ce',
'signature' => $sumAndDifferen ce_sig,
'docstring' => $sumAndDifferen ce_doc),
'display'=>
array('function ' => 'Server.display ',
'signature' => $display_sig,
'docstring' => $display_doc)
));
}
}
$test = new Server();
$server = $test->makeServer() ;
?>
Thanks in advance