I have downloaded phpxmlrpc from http://phpxmlrpc.sourceforge.net/
I have a folder on my webserver called xmlrpc-test and have a simple test php app created.
<?php
include 'xmlrpc.inc';
include 'xmlrpcs.inc';
function sumAndDifference ($params) {
// Parse our parameters.
$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'));
}
// 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('sample.sumAndDifference' =>
array('function' => 'sumAndDifference',
'signature' => $sumAndDifference_sig,
'docstring' => $sumAndDifference_doc)));
?>
I have loaded the phpxmlrpc debugger, entered the Address:, Port: and Path: but when I press the execute button for List available methods
nothing happens.
Question 1: why does my local debugger not work?
So I went online here http://phpxmlrpc.sourceforge.net/jsxmlrpc/debugger/debugger.html and it seems to work better.
However, when I press the execute button here (after entering my server details) I get the following message.
Fault code: [5] Reason: 'Didn't receive 200 OK from remote server. (send failed)'
I thought this may have meant there was something wrong with my local server and the WAN so I tested the app at http://feedvalidator.org/ and I do in fact get a response.
1. <?xml version="1.0"?>
2. <methodResponse>
3. <fault>
4. <value>
5. <struct><member><name>faultCode</name>
6. <value><int>105</int></value>
7. </member>
8. <member>
9. <name>faultString</name>
10. <value><string>XML error: Invalid document end at line 1, column 1</string></value>
11. </member>
12. </struct>
13. </value>
14. </fault>
15. </methodResponse>
I think this is an error because there is not payload being sent.
Question 2: How do I solve this? How can I get a very simple xmlrpc server working with php?
For posterity, I'll give my input.
First, Your local debugger doesn't work because of silent sabotaging by the security sandbox. The W3C and browser vendors worked out a scheme whereby the browser will silently translate the POST request your debugger is sending to an OPTION request instead. It seems like a real kludge because the browser gives no visible indication that it is doing this, but it is standard behavior. If you go into Firebug or the console and look at the network traffic you'll see it first hand.
Second, That example looks like the one from the "Master..." book about Joomla. Could well be that any of numerous flaws and configuration settings anywhere along the technology stack could be the roadblock. I just ran into the same issue today. The real lesson to learn here is, "don't do that". Use a development environment that has better tool chain support and a more straightforward path to success.