Welcome Guest, Not a member yet? Register   Sign In
XML-RPC as webservice using good MVC
#4

[eluser]gtech[/eluser]
[quote author="linuxamp" date="1196967092"]gtech,

Your comment about loading methods was another question I was going to ask but I didn't want to make my first request too long. I noticed that the XML-RPC library uses
Code:
is_callable()
to determine if the method is callable.
[/quote]
correct it does

[quote author="linuxamp" date="1196967092"]
Because of this, calling an outside method would require that the method being called is loaded before attempting to use it in the
Code:
$this->xmlrpcs->initialize($config);
line. I believe this should work but have yet to try it.
[/quote]
yes it should enable you to load methods in another controller? (needs reseach) but it doesn't, I have tried it (unless i'm missing something). I use the above method to set the config to enable the methods inside the server controller before initialising anyway.

I can kind of see why it doesn't work... If the method is in the same controller as the server controller its fine.. If the method is in another controller it doesnt work, and I am not sure how to fix it yet as when the request is received it only loads up the specific controller (in case of xmlrpc the server controller), and so the other controllers methods are not available.

I have posted up some xmlrpc fixes before so that the system methods would work eg system.listmethods is broken in 1.5.4. have a look in the bug log forum.

I am nowhere near being a CI expert however so don't know if not being able to load another controllers methods its a bug or not yet, i need to sit down and look at it properly (if it is I will log it unless you want to).






Quote: It would surely make the code more maintainable as you'd probably be reusing many existing controller methods in both your main application and webservice.

Not really, my xmlrpc code is used to make changes to the model directly, the controller functionality is different, a controller may load several models for one page.

My xmlrpc is used so other web guis can interact with my model schema, so its purley an interface into calling models. I don't see the point of an xmlrpc request calling a 'standard' controller method that loads a view, as the xmlrpc response will be meaningless, to make it work you would need to create a view and a xmlrpc response for every controller method you call.




P.S all the initialise function really does is set up an array $this->methods so the _execute function can determine if the method is expected or not.. it doesn't source in other controllers methods.

Code:
.....    
function initialize($config=array())
{    
    if (isset($config['functions']) && is_array($config['functions']))
    {
        $this->methods = $config['functions'];
    }
.....


function _execute($m)
{
    $methName = $m->method_name;
        
    // Check to see if it is a system call
    // If so, load the system_methods
    $sysCall = ereg("^system\.", $methName);
    $methods = $sysCall ? $this->system_methods : $this->methods;


I hope this helps, I might of waffled on too much, im sure my approach is not the only approach though.


Messages In This Thread
XML-RPC as webservice using good MVC - by El Forum - 12-06-2007, 01:41 AM
XML-RPC as webservice using good MVC - by El Forum - 12-06-2007, 03:21 AM
XML-RPC as webservice using good MVC - by El Forum - 12-06-2007, 06:51 AM
XML-RPC as webservice using good MVC - by El Forum - 12-06-2007, 07:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB