Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 04-05-2006, 07:59 PM   #1
Registered: Nov 2004
Location: Newport, RI, USA
Distribution: Mandriva 2006
Posts: 125

Rep: Reputation: 15
Problems setting up XMLRPC with Apache and PHP

I am new to XMLRPC, and I am having some problems.
I have a client script (rpctest.html)
<title>XML-RPC PHP Demo</title>
<h1>XML-RPC PHP Demo</h1>


// Make an object to represent our server.
$server = new xmlrpc_client('sample.php',
'', 9990);
echo "server=".$server;
echo "<br>";
echo "a";
echo "<br>";

echo "b";
echo "<br>";
// Send a message to the server.
echo "<br>";
$message = new xmlrpcmsg('messagetest', array(new xmlrpcval(5, 'int'),
new xmlrpcval(3, 'int')));
echo "c";
echo "<br>";
echo "message=".$message;
echo "<br>";
echo "Calling sumAndDifference";
$result = $server->send($message);
echo "After sumAndDifference";
echo $result;
echo "<br>";
echo "d";
echo "<br>";
// Process the response.
if (!$result) {
echo "e";
echo "<br>";
print "<p>Could not connect to HTTP server.</p>";
} elseif ($result->faultCode()) {
echo "ERROR";
print "<p>XML-RPC Fault #" . $result->faultCode() . ": " .
} else {
echo "NO ERROR";
$struct = $result->value();
$sumval = $struct->structmem('sum');
$sum = $sumval->scalarval();
$differenceval = $struct->structmem('difference');
$difference = $differenceval->scalarval();
print "<p>Sum: " . htmlentities($sum) .", Difference: " . htmlentities($difference) . "</p>";

, that calls a function in a xmlrpc server program (sample.php).
echo "Before sumAndDifference function in sample.";
function sumAndDifference ($params) {
echo "In sumAndDifference function.";
// Parse our parameters.
$xval = $params->getParam(0);
$x = $xval->scalarval();
$yval = $params->getParam(1);
$y = $yval->scalarval();
echo "x=".$x;
echo "y=".$y;

// Build our response.
$struct = array('sum' => new xmlrpcval($x + $y, 'int'),'difference' => new xmlrpcval($x - $y, 'int'));
return new xmlrpcresp(new xmlrpcval($struct, 'struct'));
echo "After function.";
// Declare our signature and provide some documentation.
// (The PHP server supports remote introspection. Nifty!)
$sumAndDifference_sig = array(array('struct', 'int', 'int'));
$sumAndDifference_doc = 'Add and subtract two numbers';
new xmlrpc_server(array('messagetest' =>array('function' => 'sumAndDifference','signature' => $sumAndDifference_sig,'docstring' => $sumAndDifference_doc)));
echo "<br>";
echo "After bind";
echo "<br>";

This is my setup (part of phpinfo()):
Apache/2.0.54 (Mandriva Linux/PREFORK-13mdk)
X-Powered-By PHP/5.0.4

core library version xmlrpc-epi v. 0.51
php extension version 0.51
author Dan Libby
open sourced by

I have also downloaded and and placed them in the default Apache directory (/var/www/html). I am not sure if this is even necessary since php has built in support for xmlrpc since php4.1

When I open rpctest.php, I don't get a response back from the function since it is not called in the sample.php server program. I don't get any errors either. This is the output I see in the browser:
server=Object id #1

message=Object id #2
Calling sumAndDifference

HTTP/1.1 200 OK
Date: Wed, 05 Apr 2006 23:33:54 GMT
Server: Apache/2.0.54 (Mandriva Linux/PREFORK-13mdk)
X-Powered-By: PHP/5.0.4
Content-Length: 58
Connection: close
Content-Type: text/html

Before sumAndDifference function in sample.After function.

HEADER: date: Wed, 05 Apr 2006 23:33:54 GMT
HEADER: server: Apache/2.0.54 (Mandriva Linux/PREFORK-13mdk)
HEADER: x-powered-by: PHP/5.0.4
HEADER: content-length: 58
HEADER: connection: close
HEADER: content-type: text/html

Any suggestions what I need to do to make this work?

Last edited by eikeland; 04-05-2006 at 08:00 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP xmlrpc problem. Jim44 Programming 0 02-20-2006 11:14 AM
Setting up PHP with Apache D4ve G SUSE / openSUSE 8 06-27-2005 11:20 AM
Setting up apache with php and mysql meander Linux - Networking 6 01-26-2005 04:10 AM
apache setting for php tej Linux - Software 2 09-20-2004 07:17 AM
Help Setting Up PHP On Apache AFI_Flame Linux - Networking 3 06-28-2004 12:44 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:21 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration