By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,701 Members | 2,006 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,701 IT Pros & Developers. It's quick & easy.

integrate php xmlrpc server

P: n/a
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("xmlrpc");
}catch(e){
throw "importing of xmlrpc module failed.";
}
doSome = function()
{
try{
var service = new
xmlrpc.ServiceProxy("http://localhost/test.php");
var something = service.Server.display();
alert(something);
}catch(e){
alert("nothing");
}
}
</script>
</head>

<body bgcolor="#D4D0C8">
<a href="javascript:doSome()">click</a>
</body>


</script>
</html>
-----------------------------------------------------------------------------------------
and test.php side:
<?php
include 'xmlrpc/xmlrpc.inc';
include 'xmlrpc/xmlrpcs.inc';

class Server
{
function Server()
{
}

function sumAndDifference ($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($struct, 'struct'));
}

function display()
{

return new xmlrpcresp(new xmlrpcval("James",
'string'));
}

function makeServer()
{
$sumAndDifference_sig = array(array('struct', 'int',
'int'));
$sumAndDifference_doc = 'Add and subtract two numbers';

$display_sig = array(array('struct'));
$display_doc = 'Add and subtract two numbers';

new xmlrpc_server(array('server.sumAndDifference' =>
array('function' => 'sumAndDifference',
'signature' => $sumAndDifference_sig,
'docstring' => $sumAndDifference_doc),
'display'=>
array('function' => 'Server.display',
'signature' => $display_sig,
'docstring' => $display_doc)
));
}
}

$test = new Server();
$server = $test->makeServer();
?>

Thanks in advance

Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.