Welcome Guest, Not a member yet? Register   Sign In
XML-RPC-server [Error: 500][Solved]
#1

[eluser]comex[/eluser]
Hello,

I'm playing around with XML-RPC and I keep getting "Internal Server Error".

Server code
Code:
class Xmlrpc extends Controller {
    function index(){
        $this->load->library('xmlrpc');
        $this->load->library('xmlrpcs');
        $this->xmlrpc->set_debug(TRUE);
        $config['functions']['Update'] = array('function' => 'Xmlrpc._update');

        $this->xmlrpcs->initialize($config);
        $this->xmlrpcs->serve();
    }
    function _update($request){
        $this->_respond();
        return;

    }

    function _respond(){
        $response = array(
                        array(
                            'flerror' => array(FALSE, 'boolean'),
                            'message' => "Thanks for the ping!"),
                            'struct');
        return $this->xmlrpc->send_response($response);
    }
        
}
The reason as to why its so convoluted with _update() calling _respond() is that I took away code for clarity. The _respond() is something I found somewhere and its supposed to be working.

Client code(Python)
Code:
import xmlrpclib

#Connect to server
server_url = 'http://127.0.0.1/index.php/rpc/xmlrpc';
server = xmlrpclib.Server(server_url);
#Send request
response = server.Update(1)
print response
The client manages to connect and so on, but raises an exception alerting of the internal server error.

Now, I've read somewhere that people using the Wordpress XML-RPC had to force PHP5 on their servers. Does that seem reasonable? Or is my code flawed? =)

Thank you.
#2

[eluser]comex[/eluser]
There. Solved.
Had to change:
Code:
function _update($request){
        $this->_respond();
        return;

  }
Into:
Code:
function _update($request){
        return $this->_respond();
  }

Huzzah.
#3

[eluser]comex[/eluser]
Hm, sorry for shamelessly bumping my own topic. Figured this was better than starting a new thread.

The XML-RPC communication is working flawlessly, sending multiple structs e.t.c..
But the server refuses to alter my database(insert, update), at the same time as reading(select) works fine.
Is this related to the fact that my server lacks an constructor?

Thank you.




Theme © iAndrew 2016 - Forum software by © MyBB