티스토리 툴바










Hello,



I have to make a Android client that will connect to the PHP server using XML-RPC. I made a simple function that sends two numbers. PHP server will receive those numbers, sum them and send them back.

Android client

Using java Syntax Highlighting
  1. import android.app.Activity;
  2.  
  3. import android.os.Bundle;
  4.  
  5. import android.widget.TextView;
  6.  
  7.  
  8.  
  9. import org.xmlrpc.android.*;
  10.  
  11.  
  12.  
  13. public class TestRpc extends Activity {
  14.  
  15.  
  16.  
  17.         private XMLRPCClient client;
  18.  
  19.         private URI uri;
  20.  
  21.  
  22.  
  23.         @Override
  24.  
  25.     public void onCreate(Bundle savedInstanceState) {
  26.  
  27.                 super.onCreate(savedInstanceState);
  28.  
  29.                
  30.  
  31.                 uri = URI.create("http://127.0.0.1/test/xmlrpc.php");
  32.  
  33.                 client = new XMLRPCClient(uri);
  34.  
  35.                
  36.  
  37.                 try {
  38.  
  39.                 // call method "add" with two parameters: 2 and 4
  40.  
  41.         int sum = (Integer) client.call("add", 2, 4);
  42.  
  43.                
  44.  
  45.                 System.out.println("suma: " + sum);
  46.  
  47.                
  48.  
  49.         Log.d("XMLRPC Test", "result int sum = " + sum);
  50.  
  51.         }       catch (XMLRPCException e) {
  52.  
  53.         Log.d("XMLRPC Test", "Error", e);
  54.  
  55.                 }
  56.  
  57. }
Parsed in 0.140 seconds, using GeSHi 1.0.8.4



PHP server

Code: Select all
<?php
include 'xmlrpc.inc';
include 'xmlrpcs.inc';

function add($number1,$number2) {
    $zbroj = $number1 + $number2;
    return $zbroj;
}
?>



And my question is will this work. I dont see where am I using XML-RPC library that is included in PHP. Of course i will add library that "pskink" provided for Android client.




출처 : http://www.anddev.org/xml-rpc_android_client_-und-amp_php_server-t13517.html

'개발업무 > ANDROID' 카테고리의 다른 글

애니메이션 예제  (0) 2010/05/20
PHP로 XML-RPC 사용하기  (0) 2010/05/19
XML-RPC: Android client & PHP server  (0) 2010/05/19
XML RPC  (0) 2010/05/19
Working with XML on Android  (0) 2010/05/19
DOM예제  (0) 2010/05/19








Posted by 홍서기 트랙백 0 : 댓글 0

댓글을 달아 주세요