Get XML-RPC (Andorid - PHP) web service different params type

Posted by Jovan on Stack Overflow See other posts from Stack Overflow or by Jovan
Published on 2010-12-31T01:06:16Z Indexed on 2010/12/31 11:53 UTC
Read the original article Hit count: 212

Filed under:
|
|
|

Hi,

I want to create XML-RPC web service for Andorid (client) - PHP (Server) communication

I create XML-RPC PHP web service server using this tutorial: http://articles.sitepoint.com/article/own-web-service-php-xml-rpc/5

For andorid client web service I use this project: http://code.google.com/p/android-xmlrpc/

server and client communication is OK, but I have problem with getting params from andorid client to php server.

From andorid client I send two params (first integer and second float number)

          Object[] params = {
        3,
        3.6f,
      };
      method.call(params);

, but I don't know how to handle this parameters in php server??

in php server there is some function , but with only one param ($news_id):

    function news_viewNewsItem ( $news_id ) {    

   /* Define the query to fetch the news item */    
   $query = "SELECT * FROM kd_xmlrpc_news WHERE news_id = '"      
   . $news_id . "'";    
   $sql = mysql_query ( $query );    
   if ( $result = mysql_fetch_array ( $sql ) ) {    

       /* Extract the variables for sending in      
       our server response */    
       $news_item['news_id'] = $result['news_id'];    
       $news_item['date'] = XMLRPC_convert_timestamp_to_iso8601(    
           mysql_datetime_to_timestamp( $result['date'] ) );          
       $news_item['title'] = $result['title'];    
       $news_item['full_desc'] = $result['full_desc'];    
       $news_item['author'] = $result['author'];    

       /* Respond to the client with the news item */    
       XMLRPC_response(XMLRPC_prepare($news_item),      
              KD_XMLRPC_USERAGENT);    
   } else {    

       /* If there was an error, respond with a      
       fault code instead */    
       XMLRPC_error("1", "news_viewNewsItem() error: Unable      
to read news:"    
           . mysql_error(), KD_XMLRPC_USERAGENT);    
   }    
}    

In server.py file there is functions for every method but I dont know how to write in php server:

def add(self, x, y): 

print print "input x=%s, y=%s" % (str(x), str(y)) sum = x + y print "output", sum print return sum

Can some one help me with code , and tell me how to handle various types from client to server??

Thanks and Happy New Year

© Stack Overflow or respective owner

Related posts about php

Related posts about android