Welcome Guest, Not a member yet? Register   Sign In
XML-RPC :: Method Introspection
#1

[eluser]PhxVyper[/eluser]
Hello,

How do I perform method introspection on my XML-RPC application?

I've tried https://mydomain/client.php?method=system.listMethods

and I've also tried writing my own method that calls the listMethods method from the server and I just get errors like "The XML data receieved was either invalid or not in the correct form for XML-RPC. Turn on debugging to examine the XML data further." or other errors.

Thx!
#2

[eluser]gtech[/eluser]
I had a long look at this code and I don't think listMethods works

[edit]

See below post for solution
#3

[eluser]gtech[/eluser]
OK got it working!

you need to make the following changes to xmlrpcs.php (dont get confused with xmlrpc.php)

Code:
// line 85
        $this->system_methods = array(

Code:
// line 262
            if ($objectCall && !is_callable(array($method_parts['0'],$method_parts['1'])) && !$sysCall)

Code:
// line 315
            if ($method_parts['0'] == "this")
            {
                return call_user_func(array($this, $method_parts['1']), $m);
            }

Code:
// line 343
        foreach($this->methods as $key => $value)

Once you have made the changes you can call it as follows (see the xmlrpc documentation as it is copied from there apart from the listMethods bit):
Code:
class myxml extends Controller {

    function index()
    {    

        // CLIENT
        $this->load->helper('url');
        $server_url = site_url('<your xml server controller name>/server');
        $this->load->library('xmlrpc');
        $this->xmlrpc->server($server_url, 80);

        // THIS IS HOW YOU CALL LISTMETHODS
        $this->xmlrpc->method('system.listMethods');
        $request = array();
        $this->xmlrpc->request($request);    
        
        if ( ! $this->xmlrpc->send_request())
        {
            echo $this->xmlrpc->display_error();
        }
        else
        {
            echo '<pre>';
            $res = $this->xmlrpc->display_response();
            print_r($res);
            echo '</pre>';
        }
    }
}
I did not need to add the system functions in the config of my existing server controller, as the system functions are configured when the xmlrpcs class is initialised. I will make a bug report and then see if anyone want to do anything with it.

[url="http://ellislab.com/forums/viewthread/65791/"](See BUG Thread)[/url] I have also included an svn patch for the fixes in the thread.
#4

[eluser]PhxVyper[/eluser]
Thanks for the details. I'm now able to list methods.

Here is the next issue.

Code:
function methodHelp($m)
    {
        $methName = $m->getParam(0);

Notice the getparam method call? It doesn't exist! So, the other system methods for system.methodHelp, system.methodSignature, and multicall don't work.
#5

[eluser]gtech[/eluser]
yes I tried calling the other system calls that require parameters. When I tried it the code keeled over when trying to parse each methods signature in the execute function.

will take a look and see if its a simple fix when I get some time from my proper job, or it may be that im calling it incorrectly Smile.
#6

[eluser]gtech[/eluser]
OK got methodhelp and method signature working (YOU ALSO NEED THE FIXES ABOVE)

xmlrpc.php
Code:
..
//line 1107 add this line
    function getParam($int) { return $this->params[$int]; }

..
//line 1387ish after the scalarval function add this function:
        function scalartyp()
        {
            global $xmlrpcI4, $xmlrpcInt;
            reset($this->me);
            list($a,$b)=each($this->me);
            if ($a==$xmlrpcI4)
            {
                $a=$xmlrpcInt;
            }
            return $a;
        }

xmlrpcs.php
Code:
..
//line 410 needs to change as well as fixes in original reply
        if (isset($methods[$method_name]))

enjoy, I spent a couple of head scratching hours doing this. I will post up my SVN PATCH on the bug report. [url="http://ellislab.com/forums/viewthread/65791/"](CLICK HERE)[/url]




Theme © iAndrew 2016 - Forum software by © MyBB