[英]how to connect(call) wcf service on xamarin android?
i have 2 project on my solution 1 android 2 wcf service application 我在解决方案1 android 2 wcf service application上有2个项目
database info: 数据库信息:
i tested my service on debug and work fine info: 我在调试中测试了我的服务并正常工作:
and , add to my android project by add reference service added successfully i can see my tables , fields and ... when i create an instance of my table on click method of my project android project run success but not affect on my database i point a break point on codes and see data to be add but no affect here is my codes 并且,通过添加参考服务成功添加到我的android项目中,我可以看到我的表,字段和...当我在我的项目android项目的单击方法上创建我的表的实例时android项目运行成功但对我的数据库没有影响代码断点,看到要添加的数据,但没有影响,这是我的代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
namespace Siman_Android
{
[Activity(Label = "PersonAddActivity")]
public class PersonAddActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
Button btn = FindViewById<Button>(Resource.Id.btnadd);
btn.Click += Btn_Click;
}
ServiceRefrence.Service1 myService = new ServiceRefrence.Service1();
private void Btn_Click(object sender, EventArgs e)
{
myService.Url=("http://localhost:13294/Service1.svc");
EditText txtname = FindViewById<EditText>(Resource.Id.txtname);
EditText txtfamily = FindViewById<EditText>(Resource.Id.txtfamily);
myService.GetPersonAsync(txtname.Text, txtfamily.Text);
}
}
}
and my service code to add person 和我的服务代码添加人
public bool GetPerson(string FirstName, string LastName)
{
try
{
PersonName pr = new PersonName()
{
Family = LastName,
Name = FirstName
};
db.PersonNames.Add(pr);
db.SaveChanges();
return true;
}
catch (Exception)
{
return false;
}
}
please help! 请帮忙!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.