Welcome Guest, Not a member yet? Register   Sign In
xml rpc issue
#1

[eluser]socs[/eluser]
I'm new to using XML RPC and trying to get it to work but seems the response is not in an XML format.

Here's my code and when my client calls my server I get the following response below...

Code:
function getTest($request)
    {    
         $parameters = $request->output_parameters();

        $site     = 0; //US
        $per_page = 20; // limit
        $cur_page = 0;

        $adslist = array();
        $this->db->where('siteid', $site);
        $query = $this->db->get('ad', $per_page, $cur_page);  
            
        $count = 0;
        $arraymap = array();  
        foreach($query->result() as $row){        

            $arraymap[$count] = array(  
                                  array(  
                    'title'=> array($row->title,'string'),    //TODO cdata and html strip  
                    'id'=> array($row->id,'string'),    
                    'price'=> array($row->price,'string'),
    
                  ),'struct');              


              $count = $count + 1;

        }

        $response = array(
                          array('total'     => array($count,'string'),
                                'category'  => array($category, 'string'),
                                'items'     => array($arraymap, 'array'),
                                ),
                         'struct');  


        return $this->xmlrpc->send_response($response);

    }

And here's the response. Shouldn't this be in xml format ?
2/10/09 10:59:55 AM ListBiteTicket[4274] result:{
category = 0;
items = (
{
id = 6836;
price = "180.00";
title = "Tiny Yorkie puppies Available !!";
},
{
id = 6837;
price = "0.00";
title = " Affectionate Yorkie Puppies For Adoption ";
},
{
id = 6843;
price = "0.00";
title = "Teacup size yorkies,maltese & chihuahua on sale";
},
{
id = 6844;
price = "400.00";
title = "excellent english bulldog for free adoption";
},
{
id = 10135;
price = "0.00";
title = "Free Tea Cup Yorkie Puppies For Adoption ";
},
{
id = 10136;
price = "0.00";
title = "Free Tea Cup Yorkie Puppies For Adoption ";
},
{
id = 6833;
price = "400.00";
title = "CUTE MALE AND FEMALE BABY CAPUCHIN MONKEYS FOR ADOPTION ";
},
{
id = 6839;
price = "1.00";
title = " Hiring Ad Paste ";
},
{
id = 6852;
price = "0.00";
title = "Hiring Ad Paste \"basit09\"";
},
{
id = 6847;
price = "1.00";
title = "Hiring Ad Paste \"hannibal13\"";
},
{
id = 6846;
price = "0.00";
title = "The Day The Towers Fell ";
},
{
id = 6838;
price = "10.00";
title = "Revenge Denied";
},
{
id = 6840;
price = "0.00";
title = " Hiring Ad Paste ?Arshad28?";
},
{
id = 6848;
price = "19.95";
title = "The Joy of Being ";
},
{
id = 10138;
price = "24.95";
title = "Sinking the Ship of State (Book) ";
},
{
id = 1027;
price = "0.00";
title = "On Vacation";
},
{
id = 6317;
price = "0.00";
title = "Short Term Vacation Rentals In Jerusalem ";
},
{
id = 6320;
price = "0.00";
title = "South Lake Tahoe Vacation Home";
},
{
id = 6332;
price = "0.00";
title = "Hillcrest Guest House, US Virgin Islands";
},
{
id = 6333;
price = "0.00";
title = "Hillcrest Guest House, US Virgin Islands";
}
);
total = 20;
}
#2

[eluser]Nick Husher[/eluser]
What URL are you using to access the XML-RPC function?
#3

[eluser]socs[/eluser]
I'm calling the server for my api url with the method name in the rpc request set to 'GetTest'.
Code:
function index()
    {
        $this->load->library('xmlrpc');        
        $this->load->library('xmlrpcs');
          
        $config['functions']['GetTest'] = array('function' => 'Api.getTest');
                
        $this->xmlrpcs->initialize($config);  
        $this->xmlrpcs->serve();
    }
#4

[eluser]Nick Husher[/eluser]
I'm going to guess and say that you're hitting "/index.php/Api/getTest", when you need to be sending an XML-RPC-formulated request to "/index.php/Api"
#5

[eluser]socs[/eluser]
I'm actually calling it from an iphone/objective C app,
and looks like using an alternate tool to call it,
it is returning the correct xml.

guess obj-c is somehow reforming it into the non xml format.
Code:
obj-c code in case your interested..
    rpcCall = WSMethodInvocationCreate ((CFURLRef) rpcURL, (CFStringRef) methodName, kWSXMLRPCProtocol);    
    WSMethodInvocationSetParameters (rpcCall, (CFDictionaryRef) params, NULL);
    // set debug props
    WSMethodInvocationSetProperty(rpcCall, kWSDebugIncomingBody, kCFBooleanTrue);
    WSMethodInvocationSetProperty(rpcCall, kWSDebugIncomingHeaders, kCFBooleanTrue);
    WSMethodInvocationSetProperty(rpcCall, kWSDebugOutgoingBody, kCFBooleanTrue);
    WSMethodInvocationSetProperty(rpcCall, kWSDebugOutgoingHeaders, kCFBooleanTrue);
    
    //WSDebugInBody
    result = (NSDictionary *) (WSMethodInvocationInvoke (rpcCall));

        NSString* strresult = [result objectForKey:( NSString* ) kWSMethodInvocationResult ];




Theme © iAndrew 2016 - Forum software by © MyBB