tags:

views:

94

answers:

0

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?