Start with XML RPC

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Start with XML RPC

Postby milo » Sat Jun 20, 2009 12:49 am

Hello,

I start the development on Android, I have make the "Hello World". Now I want make an application with XML RPC.
I have read the tuto on XML RPC on this forum. I have donwload the latest version of the librairy on SVN.

But I don't understund how use this. I have make the exemple with a real XML RPC, but when I run my application, nothing go to screen.


This is my code :
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. import android.app.Activity;
  3.  
  4. import android.os.Bundle;
  5.  
  6. import android.widget.TextView;
  7.  
  8.  
  9.  
  10. import org.xmlrpc.android.*;
  11.  
  12.  
  13.  
  14. public class MagenToid extends Activity {
  15.  
  16.     /** Called when the activity is first created. */
  17.  
  18.     @Override
  19.  
  20.     public void onCreate(Bundle savedInstanceState) {
  21.  
  22.         super.onCreate(savedInstanceState);
  23.  
  24.                
  25.  
  26.         TextView session = new TextView(this);
  27.  
  28.         String apiLogin="toto";
  29.  
  30.         String apiKey="password";
  31.  
  32.        
  33.  
  34.         XMLRPCClient client = new XMLRPCClient("http://www.url.com/api/xmlrpc/");
  35.  
  36.                  
  37.  
  38.         try {
  39.  
  40.                 //I have a webservice "Login" accepte 2 parameter login and password
  41.  
  42.                 session = (TextView) client.call("login", apiLogin, apiKey);
  43.  
  44.                 setContentView(session);
  45.  
  46.         } catch (XMLRPCException e) {
  47.  
  48.         // Auto-generated catch block
  49.  
  50.                 e.printStackTrace();
  51.  
  52.         }
  53.  
  54.     }
  55.  
  56. }
  57.  
  58.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


with this webservice "Login", session become a string.
I want print the variable session on screen like "hello world".

The project run whitout problem, but don't show the string session.

I am a noob on android, If somebody can help me, and show my mistake.

Thank you.
milo
Freshman
Freshman
 
Posts: 4
Joined: Sat Jun 20, 2009 12:27 am

Top

Re: Start with XML RPC

Postby pskink » Sat Jun 20, 2009 9:38 am

i'd try:

String result = (String)client.call("login", apiLogin, apiKey);
session.setText(result);
pskink
pskink
Master Developer
Master Developer
 
Posts: 719
Joined: Mon Nov 24, 2008 3:49 pm

Postby milo » Mon Jun 22, 2009 10:52 am

thank you.

i can see my string. I have some mistake, but now I can see the result :)
milo
Freshman
Freshman
 
Posts: 4
Joined: Sat Jun 20, 2009 12:27 am

Postby milo » Mon Jun 22, 2009 9:24 pm

I have a new problem.

My application write this error :
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Error java.net.SocketExeption: Permission denied (maybe missing INTERNET permission)
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


I don't understund, because I have Internet, I can surf on website with this emulator of google phone on eclipse.

When I start the debug, I can see in the LogCat :
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Unknown host XXXX.url.com, throwing UnknownHostException
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


Thank you for your help.
milo
Freshman
Freshman
 
Posts: 4
Joined: Sat Jun 20, 2009 12:27 am

Postby pskink » Tue Jun 23, 2009 12:14 pm

milo wrote:I have a new problem.

My application write this error :
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Error java.net.SocketExeption: Permission denied (maybe missing INTERNET permission)
Parsed in 0.035 seconds, using GeSHi 1.0.8.4



you have to add INTERNET permission to your Manifest, see Manifest of xml-rpc sample application
pskink
pskink
Master Developer
Master Developer
 
Posts: 719
Joined: Mon Nov 24, 2008 3:49 pm

Postby milo » Tue Jun 23, 2009 2:42 pm

All rigths. I see my error.

One thank you to you pskink. :wink:
milo
Freshman
Freshman
 
Posts: 4
Joined: Sat Jun 20, 2009 12:27 am

Top

Re: Start with XML RPC

Postby dj_4war » Tue Apr 27, 2010 5:34 am

this wat am looking for milo....
but i need server side implementation ..... milo....


please can u provide server side code.......



its a urgent,,,,,,,,,,,,,,,,


milo wrote:Hello,

I start the development on Android, I have make the "Hello World". Now I want make an application with XML RPC.
I have read the tuto on XML RPC on this forum. I have donwload the latest version of the librairy on SVN.

But I don't understund how use this. I have make the exemple with a real XML RPC, but when I run my application, nothing go to screen.


This is my code :
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. import android.app.Activity;
  2. import android.os.Bundle;
  3. import android.widget.TextView;
  4.  
  5. import org.xmlrpc.android.*;
  6.  
  7. public class MagenToid extends Activity {
  8.     /** Called when the activity is first created. */
  9.     @Override
  10.     public void onCreate(Bundle savedInstanceState) {
  11.         super.onCreate(savedInstanceState);
  12.                
  13.         TextView session = new TextView(this);
  14.         String apiLogin="toto";
  15.         String apiKey="password";
  16.        
  17.         XMLRPCClient client = new XMLRPCClient("http://www.url.com/api/xmlrpc/");
  18.                  
  19.         try {
  20.                 //I have a webservice "Login" accepte 2 parameter login and password
  21.                 session = (TextView) client.call("login", apiLogin, apiKey);
  22.                 setContentView(session);
  23.         } catch (XMLRPCException e) {
  24.         // Auto-generated catch block
  25.                 e.printStackTrace();
  26.         }
  27.     }
  28. }
  29.  
Parsed in 0.039 seconds, using GeSHi 1.0.8.4


with this webservice "Login", session become a string.
I want print the variable session on screen like "hello world".

The project run whitout problem, but don't show the string session.

I am a noob on android, If somebody can help me, and show my mistake.

Thank you.
dj_4war
Junior Developer
Junior Developer
 
Posts: 10
Joined: Thu Apr 01, 2010 7:49 am

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests