Welcome Guest, Not a member yet? Register   Sign In
XMLRPC
#1

[eluser]Jamie Rumbelow[/eluser]
Having a little trouble with the XML-RPCS, this is my server class:

Code:
$config['functions']["getLatestPost"] = array("function"=>"News.getLatestPost");
        $config['functions']["getPosts"] = array("function"=>"News.getPosts");

        $config['object'] = $this;
        
        $this->xmlrpcs->initialize($config);
        $this->xmlrpcs->serve();

And my request:

Code:
...
$this->xmlrpc->server($site_url, 80);
        $this->xmlrpc->method('getLatestPost');
        
        $request = array("0000000000");
        $this->xmlrpc->request($request);
...

My Response, when I die(print_r($this->methods));

Code:
---DATA---
HTTP/1.1 200 OK
Date: Fri, 13 Jun 2008 21:35:40 GMT
Server: Apache/2.2.8 (Win32) DAV/2 mod_ssl/2.2.8 OpenSSL/0.9.8g mod_autoindex_color PHP/5.2.5
X-Powered-By: PHP/5.2.5
Content-Length: 2069
Connection: close
Content-Type: text/html

Array
(
    [system.listMethods] => Array
        (
            [function] => this.listMethods
            [signature] => Array
                (
                    [0] => Array
                        (
                            [0] => array
                            [1] => string
                        )

                    [1] => Array
                        (
                            [0] => array
                        )

                )

            [docstring] => Returns an array of available methods on this server
        )

    [system.methodHelp] => Array
        (
            [function] => this.methodHelp
            [signature] => Array
                (
                    [0] => Array
                        (
                            [0] => string
                            [1] => string
                        )

                )

            [docstring] => Returns a documentation string for the specified method
        )

    [system.methodSignature] => Array
        (
            [function] => this.methodSignature
            [signature] => Array
                (
                    [0] => Array
                        (
                            [0] => array
                            [1] => string
                        )

                )

            [docstring] => Returns an array describing the return type and required parameters of a method
        )

    [system.multicall] => Array
        (
            [function] => this.multicall
            [signature] => Array
                (
                    [0] => Array
                        (
                            [0] => array
                            [1] => array
                        )

                )

            [docstring] => Combine multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details
        )

    [getLatestPost] => Array
        (
            [function] => News.getLatestPost
        )

    [getPosts] => Array
        (
            [function] => News.getPosts
        )

)
1
---END DATA---


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.

I'm getting a "Method not found" error when I don't "die"

Could somebody give me some help?
#2

[eluser]gtech[/eluser]
what does your news controller look like?
#3

[eluser]Jamie Rumbelow[/eluser]
Hey, here is my news controller:

Code:
class News extends Controller {

    function News(){
        parent::Controller();
    }

    function getLatestPost($request){
        
        
        $params = $request->output_parameters();
        
        $auth = api_key_check($params['0']);
        
        if (!$auth){return $this->xmlrpc->send_error_message("100","Your API Key is Invalid!"); } else {
            
            $this->db->orderby("id", "desc");
            $this->db->limit("1");
            $get = $this->db->get("news");
            $a = $get->result_array();
            
            $response = array(
                
                $a,'struct'
                
            );
            
            return $this->xmlrpc->send_response($response);
            
        }
        
        
        
    }

}
#4

[eluser]gtech[/eluser]
how odd I get the same error, I will take a look.
#5

[eluser]Jamie Rumbelow[/eluser]
Cheers.
#6

[eluser]gtech[/eluser]
If you move the getLatestPost function to the same controller as the Server it works, if you move it to an external controller it fails.. humm the plot thickens, I need to check if we are supposed to be able to call across controllers when using xmlrpc. (I thought you could)
#7

[eluser]gtech[/eluser]
Well it looks like you cannot call external controllers. It fails on line 270 of the xmlrpcs.php code, as its trying to use is_callable on a controller/method that has not been loaded in the request, and so it fails.

I am unsure if this is a bug or not.

If you include news.php at the top of your server you will get a different error, if you rename the function you will see it goes back to the method not found error, so it suggests the the XMLRPC does not even attempt to source in the external controller.

Also if you look at line 325 of xmlrpcs there is commented out code which attempts to call an external controller but has obviously been commented out as it did not work, however the code will never get this far as it fails gracefully on line 270.
#8

[eluser]gtech[/eluser]
I have started a bug thread:
[url="http://ellislab.com/forums/viewthread/82321/"]http://ellislab.com/forums/viewthread/82321/[/url]

please feel free to add to it.




Theme © iAndrew 2016 - Forum software by © MyBB