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
PHP server
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
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
-
import android.app.Activity;
-
-
import android.os.Bundle;
-
-
import android.widget.TextView;
-
-
-
-
import org.xmlrpc.android.*;
-
-
-
-
public class TestRpc extends Activity {
-
-
-
-
private XMLRPCClient client;
-
-
private URI uri;
-
-
-
-
@Override
-
-
public void onCreate(Bundle savedInstanceState) {
-
-
super.onCreate(savedInstanceState);
-
-
-
-
uri = URI.create("http://127.0.0.1/test/xmlrpc.php");
-
-
client = new XMLRPCClient(uri);
-
-
-
-
try {
-
-
// call method "add" with two parameters: 2 and 4
-
-
int sum = (Integer) client.call("add", 2, 4);
-
-
-
-
System.out.println("suma: " + sum);
-
-
-
-
Log.d("XMLRPC Test", "result int sum = " + sum);
-
-
} catch (XMLRPCException e) {
-
-
Log.d("XMLRPC Test", "Error", e);
-
-
}
-
-
}
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 |
xmlrpc.inc
댓글을 달아 주세요