Welcome Guest, Not a member yet? Register   Sign In
XMLRPC Server Issue -- Method Not Found
#1

[eluser]ian r livingstone[/eluser]
I keep getting the following error:

This is not a known method for this XML-RPC Server

Results from when I query the XML-RPC server using xmlrpclib in Python:

Code:
Code:
import xmlrpclib

rpc = xmlrpclib.ServerProxy("http://localhost/clanware/eve_data/index.php/api")

print rpc.system.listMethods()
#print rpc.test('test')
print rpc.categories.get('waohoah')

Result:
Code:
ian@ian-laptop:~/Desktop/clanware/api_tests$ python eve_data.py
['system.listMethods', 'system.methodHelp', 'system.methodSignature', 'system.multicall', 'blueprints.get_all', 'blueprints.get', 'groups.get', 'categories.get']
Traceback (most recent call last):
  File "eve_data.py", line 7, in <module>
    print rpc.categories.get('waohoah')
  File "/usr/lib/python2.6/xmlrpclib.py", line 1199, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1489, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.6/xmlrpclib.py", line 1253, in request
    return self._parse_response(h.getfile(), sock)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1392, in _parse_response
    return u.close()
  File "/usr/lib/python2.6/xmlrpclib.py", line 838, in close
    raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: 'This is not a known method for this XML-RPC Server'>

XML-RPC Server Code:
Code:
&lt;?php
class Api extends Controller {
    
    /*
    *    API Controller
    */
    
    public function Api () {
        
        /*
        *    API Constructor
        */
        
        parent::Controller();
        
        #    Load Config
        $this->config->load('api', TRUE);
        
    }
    
    public function index () {
        
        /*
        *    API Index
        */
        
        #    Load Configuration
        $config = array();
        $config['functions']['blueprints.get_all'] = array('function' => 'Api.get_all');
        $config['functions']['blueprints.get'] = array('function' => 'Blueprints.get');
        $config['functions']['groups.get'] = array('function' => 'Groups.get');
        $config['functions']['categories.get'] = array('function' => 'Categories.get_all');
        $config['object'] = $this;
        
        #    Initialize and Serve
        $this->xmlrpcs->initialize($config);
        $this->xmlrpcs->serve();
        
    }
}
/*EOF*/

Categories Controller Class
Code:
&lt;?php
class Categories extends API_Controller {

    /*
    *    Groups Controller
    */
    
    public function Groups () {
        
        /*
        *    Constructor
        */
        
        parent::API_Controller();
        
        $this->load->model('categories_model');
    }
    
    public function get_all ($request) {
        
        /*
        *    Return List of Categories
        */
        
        $params = $request->output_parameters();
        
        #    API Key Check
        if (!$this->check_key($params['0']))
            return $this->key_error();
            
        $data = $this->groups_model->get_all();
        $resp = array(array(), 'array');
        foreach ($data->result() as $row) {
            $resp[0][] = array(array(
                                        'categoryID' => array($row->categoryID, 'int'),
                                        'categoryName' => array($row->categoryName, 'string')
                                    ),
                                    'struct'
                              );
        }
        
        return $this->xmlrpc->send_response($resp);
    }
}
/*EOF*/

PHP Test Code
Code:
function test () {
        
        $this->xmlrpc->server("http://localhost/clanware/eve_data/index.php/api/", 80);
        $this->xmlrpc->method('categories.get');
        
        $request = array('woohooOOo');
        $this->xmlrpc->request($request);    
        
        if ( ! $this->xmlrpc->send_request())
        {
            echo $this->xmlrpc->display_error();
        }
        else
        {
            echo '<pre>';
            print_r($this->xmlrpc->display_response());
            echo '</pre>';
        }
        
    }

Lastly, the API_Controller, I dunno -- maybe this is the issue?
Code:
&lt;?php
/*
*    Controller Modules
*/

class API_Controller extends Controller {
    
    /*
    *    API Controller
    */
    
    public $isValid = False;
    
    function API_Controller () {
    
        /*
        *    Constructor
        */
        
        parent::Controller();
        
        $this->lang->load('api', 'english');
    }
    
    public function check_key ($apikey) {
        
        /*
        *    Check API Key Validity
        */
        
        return $this->api_model->check_key($apikey);
    }
    
    public function key_error () {
    
        /*
        *    Output API Key Error
        */
        
        $lang = $this->lang->load('invalid_key');
        return $this->xmlrpc->send_error_message($lang[0], $lang[1]);
    }
    
    public function param_error ($param) {
        
        /*
        *    Output a Parameter Error
        */
        
        $lang = $this->lang->load('invalid_key');
        return $this->xmlrpc->send_error_message($lang[0], $lang[1] % param);
    }
}
/*EOF*/

Anyways, when I functions into the API Class for testing purposes they work, and I tried to see if there were any errors being generated by the API_Controller, but nope. I'm pretty lost on this one, any ideas?
#2

[eluser]gtech[/eluser]
Hello,

I have not used CI for ages (1.4) but I remember comming across the same problem.

firstly I assume you have loaded your libraries
Code:
$this->load->library('xmlrpc');
    $this->load->library('xmlrpcs');

    $config = array();
    /* this will work */
    $config['functions']['blueprints.get_all'] = array('function' => 'Api.get_all');
    /* this wont as it will attempt call another controllers method from the api controller... */
    $config['functions']['categories.get'] = array('function' => 'Categories.get_all');
....

From memory you cannot call a controller from another controller in CI, and this is what you are doing by calling Categories.get_all from your Api controller.

So even though the xmlrpc library suggests you can call functions from outside the xmlrpcserver controller.. you simply can't as the code is not designed to do this.

If you move your Categories.get_all function to the Api class you will probably find it will work..

let me know how you get on. (I can't remember if I logged a bug about this, but it might make sense noteing somthing down in the CI docs?)
#3

[eluser]ian r livingstone[/eluser]
According to the user guide you can do that, http://ellislab.com/codeigniter/user-gui...mlrpc.html, so either user guide is wrong or I have some sort of mistake.
#4

[eluser]gtech[/eluser]
your right in respect that the guide says you can.. I am sure it is a bug, as I have spent ages head scratching this ages ago, and I remember reading through the code to see what it was doing, and it was trying to load the method from another controller, I put loads of debug to see where it was keeling over and it was keeling at that point... it looks like the problem is still there.

If you move your method to the api controller I bet you it will work (just to humour me that loading to another controller is the problem)

you could move your function code to a librabry if you want to abstract it. I am sure I mentioned this in the bug forum before, but it could of got overlooked.
#5

[eluser]ian r livingstone[/eluser]
alright, yea, I was going to look through the XMLRPCS lib, but just hadn't gotten around to it.
#6

[eluser]gtech[/eluser]
I wasn't going mad

[url="http://codeigniter.com/bug_tracker/bug/4300/"]bug report[/url]

however I don't think this problem has been resolved.. or the docs are confusing, hence why you have recently stumbled across the same problem.

might be worth adding your pennies worth?




Theme © iAndrew 2016 - Forum software by © MyBB