The RPCdemo of CI framework can't run well.

The RPC library recommended by the

CI official documentation is XMLrpc, where ide/libraries/xmlrpc.html" rel=" nofollow noreferrer "> official demo is as follows

ide/libraries/xmlrpc.html-sharpid15" rel=" nofollow noreferrer "> client
create a controller Xmlrpc_client.php using a text editor. In this controller, paste the following code and save it to the applications/controllers/ directory:

<?php

class Xmlrpc_client extends CI_Controller {

    public function index()
    {
        $this->load->helper("url");
        $server_url = site_url("xmlrpc_server");

        $this->load->library("xmlrpc");

        $this->xmlrpc->server($server_url, 80);
        $this->xmlrpc->method("Greetings");

        $request = array("How is it going?");
        $this->xmlrpc->request($request);

        if ( ! $this->xmlrpc->send_request())
        {
            echo $this->xmlrpc->display_error();
        }
        else
        {
            echo "
";
            print_r($this->xmlrpc->display_response());
            echo "
" } } } ? >

ide/libraries/xmlrpc.html-sharpid16" rel=" nofollow noreferrer "> Server
create a controller Xmlrpc_server.php using a text editor. In this controller, paste the following code and save it to the applications/controllers/ directory:

<?php

class Xmlrpc_server extends CI_Controller {

    public function index()
    {
        $this->load->library("xmlrpc");
        $this->load->library("xmlrpcs");

        $config["functions"]["Greetings"] = array("function" => "Xmlrpc_server.process");

        $this->xmlrpcs->initialize($config);
        $this->xmlrpcs->serve();
    }


    public function process($request)
    {
        $parameters = $request->output_parameters();

        $response = array(
            array(
                "you_said"  => $parameters[0],
                "i_respond" => "Not bad at all."
            ),
            "struct"
        );

        return $this->xmlrpc->send_response($response);
    }
}

uses the version CodeIgniter v2.1.0

however, the running result is (an error is also reported in version 3.1.9)

The XML data received was either invalid or not in the correct form
for XML-RPC. Turn on debugging to examine the XML data further.

Q: how to solve this kind of error reporting, and what other RPC plug-ins can be used by the CI framework?

Mar.31,2022

depends on the actual return value, the guess is basically a mistake reported by the server. Adjust the code according to the error.

Menu