integrate php xmlrpc server

This is a discussion on integrate php xmlrpc server within the PHP Language forums, part of the PHP Programming Forums category; Hi I am trying to integrate the xmlrpc server into a class, does anyone know how to get it working? ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-18-2005
glin@tollnz.co.nz
 
Posts: n/a
Default integrate php xmlrpc server

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

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 11:05 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0