Как исправить XML-RPC Client, возвращающий код ошибки в PHP?

Это мой первый опыт работы с XML-RPC. У меня возникла проблема с получением данных с сервера, поскольку они возвращаются клиенту в виде кода ошибки. Почему это происходит? Мне также нужно создать файл сервера XML-RPC или он уже настроен здесь?

$beerClient = new xmlrpc_client('localhost:1234/341/xmlrpc-lab/xmlrpcserver.php','alvin.ist.rit.edu:8100',1234); 

Это потому, что данные не соответствуют типу возврата сервера или что-то еще, что я упускаю?

Я убедился, что включил библиотеки xmlrpc по правильному пути и все такое.

Ошибка веб-страницы возвращает:

An XML-RPC Fault Occured
Fault Code:-1
Fault Desc:java.lang.NoSuchMethodException: BeerHandler.List()

Клиент XML-RPC:

<?php

    require_once('xmlrpc-3.0.0.beta/lib/xmlrpc.inc');

    //  Initialize $Beers as an empty Array. 
    //  $Beers will hold all the information available for each beer. 
    //     (BeerID, Name, Rating, Comments)
    //  
    //  It will be used later to create the HTML output.
    $Beers = Array();

    //  GET A LIST OF THE AVAILABLE BEERS ON THE XML-RPC SERVER

    $beerClient = new xmlrpc_client('localhost:1234/341/xmlrpc-lab/xmlrpcserver.php','alvin.ist.rit.edu:8100',1234);
    $msg_listBeers = new xmlrpcmsg('beer.List');
    $response = $beerClient->send($msg_listBeers);
    if($response == false)
    {
        die('Unable to contact XML-RPC Server');
    }
    if(!$response->faultCode()) // faults occurred?
    {
        // convert to a more usable PHP Array
        $beerList = xmlrpc_decode($response->value());
        foreach($beerList as $beerID => $beerName)
        {
           //  for each available beer listed by the server grab it's
           //    a) Rating
           //    b) Comments
           //  
           //  and put the data into the $Beer array. This is incredibly
           //  inefficient since it performs a lot of HTTP calls to grab each
           //  piece of data. Not recommended for use beyond this example.
           $Beers[$beerID]['name'] = $beerName;

           // GET THE RATING FOR THE CURRENT BEER
           // Build XML-RPC Request for the Beer's Rating

           $msg_beerRating = new xmlrpcmsg('beer.Rating',array(new xmlrpcval($beerID, 'int')));

           // Send the Message to the server
           $response = $beerClient->send($msg_beerRating);

           // Negative number If no rating found
           $Beers[$beerID]['rating'] = (!$response->faultCode()) ? xmlrpc_decode($response->value()) : -1;

           //  GET THE COMMENTS FOR THE CURRENT BEER

           $msg_beerComments = new xmlrpcmsg('beer.Comments', array(new xmlrpcval($beerID,'int')));

           // Send the Message to the server
           $response = $beerClient->send($msg_beerComments);

           // Fill in the Comments for the Beer
           $Beers[$beerID]['comments'] = (!$response->faultCode()) ? xmlrpc_decode($response->value()) : array(); //empty array for not Comments

        } // END foreach ($beerList as ...
    }
    else // XML-RPC returned a fault...
    {
        echo '<h1>An XML-RPC Fault Occured</h1>';
        printf('<b>Fault Code:</b>%s<br/>',$response->faultCode());
        printf('<b>Fault Desc:</b>%s<br/>',$response->faultString());
        die();
    }

    // GENERATE THE OUTPUT





    $xmlrpc_client->setDebug(1); // turn on debugging, if I/O fault occurred between communication xmlrpc_client and xmlrpc_server
?>


<html>
<head>
    <title>Beer List XML-RPC</title>
    <meta charset="utf-8">
</head>
<body>
    <h1>Beer List</h1>
    <ol type="1">
        <?php
            if(count($Beers))
            {
                foreach($Beers as $BeerData)
                {
                    printf('<font size="+2" color="#990000"><li> %s</font><br>', $BeerData['beer']);

                    // Output the beer's rating if it exists
                    if($BeerData['rating'] != -1)
                    {
                        printf('<b>Rating: %s/5.0</b><br>',$BeerData['rating']);
                    }

                    // Output the beer's comments if they exist
                    if(count($BeerData['comments']))
                    {
                        echo '<b>Comments:</b><ul>';
                        foreach($BeerData['comments'] as $Comment)
                        {
                            echo "<li> $Comment";
                        }
                        echo '</ul>';
                    }
                }
            }
            else
            {
                echo '<li> Darn No Beers Found';
            }
        ?>
    </ol>
</body>
</html>

person TheAmazingKnight    schedule 19.10.2014    source источник
comment
Проверьте это и this, они связаны с WordPress, но должны быть адаптируемыми. Если я правильно помню, у меня были проблемы с xmlrpc_decode.   -  person brasofilo    schedule 20.10.2014