In this application I will describe how to consume a web service in your MonoDroid application using VS 2010. (MonoDroid will not work in VS 2010 Express edition).
To install MonoDroid navigate to http://mono-android.net/Installation
Follow the instructions and download all the necessary files.
Figure 1.

In the Figure 1. I have created a new MonoDroid application named monoAndroidapplication.

Now Like Figure 2 go to Project -> Add Web Reference. Enter in the URL of your web service and click Add Reference I will consume a webservice (http://soatest.parasoft.com/calculator.wsdl) which will add 2 values and will display. In this webservice you can also perform division and multiplication.
Now In the Activity.cs file you have to write the code below.
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace MonoAndroidApplicationListView
{
[Activity(Label = "MonoAndroidApplicationListView", MainLauncher = true)]
public class Activity1 : Activity
{
int count = 1;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
// Create a new Button and set it as our view
//Button button = FindViewById<Button>(Resource.Id.MyButton);
Button button = new Button(this);
button.Text = "Consume!";
button.Click += button_Click;
SetContentView(button);
//button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); };
}
private void button_Click(object sender, System.EventArgs e)
{
// Create our web service and use it to add 2 numbers
var ws = new Calculator();
var result = ws.add(25, 10);
// Show the result in a toast
Toast.MakeText(this, result.ToString(), ToastLength.Long).Show();
}
}
}
Now in the figure below you will see the web service marked in red.
Run the Code by pressing F5 and you will see the result.
Note: Web services take time to access. Consider running them in a background thread. So be patient.

arman bayPosted Dec 16, 2014, 1:15 PM
where is WCF project Source ?
priyanka singheditedPosted Feb 22, 2013, 3:28 AMEdited Feb 22, 2013, 4:57 AM
i m working with mono android through web service.I want to search data from sql server database via webservice using monoandroid emulator.i'm getting error System.Net.Sockets.SocketException: Connection refused at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in <filename unknown>:0 at System.Net.WebConnection.Connect (System.Net.HttpWebRequest request) [0x00000] in <filename unknown>:0 --- End of inner exception stack trace --- at System.Net.HttpWebRequest.EndGetRequestStream (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 at System.Net.HttpWebRequest.GetRequestStream () [0x00000] in <filename unknown>:0 at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke (System.String method_name, System.Object[] parameters) [0x00000] in <filename unknown>:0 }.Is connectivity coding doesnot work on emulator.Kindly suggest me something.
sreenivas karthikaPosted Jan 23, 2013, 7:47 AM
Nice application, Thanks..!!
dinesh babuPosted Dec 25, 2012, 7:32 AM
Hi ,Guys, i m working with mono android through web service. I want to store data from monodroid application to sql server through web service. monodroid ==> Web Service ==> Sql server Actually i tried for asp.net with sql server via web service. its work fine for this appraoch. The data inserted into sql server. asp.net ==> Web Service ==> sql server. but when i tried this similar way for monodroid,the data not yet stored in sql server database. Here is my code for Web service: SqlConnection conn = new SqlConnection(@"Data Source=DINESH-PC\SQLEXPRESS;Initial Catalog=remotedb;Integrated Security=True"); SqlCommand com; public Service1 () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] public string insert(string name) { com = new SqlCommand("insert into dinesh values('" + name + "')", conn); conn.Open(); com.ExecuteNonQuery(); conn.Close(); return "Hello World"; } } Here is my code for monodroid public class Activity1 : Activity { localhost.Service1 suresh = new localhost.Service1(); string dinesh; protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById<Button>(Resource.Id.MyButton); EditText e1=FindViewById<EditText>(Resource.Id.editText1); button.Click += delegate { dinesh = suresh.insert(e1.Text); }; } } } Help me,Is there anything i need to change in coding or i need to change any settings to access web service in monodroid?
baba babaPosted Dec 17, 2012, 1:46 AM
Hey, I'm trying with a simple hello world web services running on my locale IIS, I get error, therefore I would love to see one of your web methods within calculator service. thank you
baba babaPosted Dec 16, 2012, 9:29 AM
thnx man, can we get your web service code?
vijay kumar sPosted Oct 15, 2012, 3:55 AM
Nice one for beginners
felipe sosa gazgaPosted Aug 17, 2012, 6:06 PM
no me aparece mi aplicacion en el emulador por que ?
Mahesh ChandPosted Mar 16, 2011, 10:41 AM
Good work! Nice to see more and more guys building Mono apps.
Karthikeyan AnbarasanPosted Mar 15, 2011, 10:01 AM
Do this framework is licensed to use in development?