I am new to developing apps in windows phone can any one tell me the client side code
I created windows azure project(for connect with sql azure project)using EDM
Here is my server side code
[ServiceContract]
public interface IService1
{
[OperationContract]
void Insert(emp x);
}
[DataContract]
public class emp
{
[DataMember]
public int id;
[DataMember]
public string name;
[DataMember]
public int sal;
[DataMember]
public string paswrd;
}
public static class convert
{
public static employee ConvertempToemployee(emp x)
{
employee b = new employee();
b.ID = x.id;
b.Name = x.name;
b.Salary = x.sal;
b.password = x.paswrd;
return b;
}
}
public trubyteEntities y;
public void Insert(emp x)
{
y = new trubyteEntities();
employee insrt = convert.ConvertempToemployee(x);
y.AddObject("employees", insrt);
y.SaveChanges();
}
Here is my Client side code
private ServiceReference1.Service1Client a;
// Constructor
public MainPage()
{
InitializeComponent();
a = new ServiceReference1.Service1Client();
a.InsertCompleted+=new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(a_InsertCompleted);
textBox1.Text=e
}
private void button1_Click(object sender, RoutedEventArgs e)
{
a.InsertAsync( =>from here i dont know the procedure
//here it showing server class emp object x
}
chandana G
Member
7 Points
69 Posts
how to consume wcf service in windows phone app
Apr 23, 2012 05:07 AM|LINK
Hi Friends,
I am new to developing apps in windows phone can any one tell me the client side code
I created windows azure project(for connect with sql azure project)using EDM
Here is my server side code
[ServiceContract]
public interface IService1
{
[OperationContract]
void Insert(emp x);
}
[DataContract]
public class emp
{
[DataMember]
public int id;
[DataMember]
public string name;
[DataMember]
public int sal;
[DataMember]
public string paswrd;
}
public static class convert
{
public static employee ConvertempToemployee(emp x)
{
employee b = new employee();
b.ID = x.id;
b.Name = x.name;
b.Salary = x.sal;
b.password = x.paswrd;
return b;
}
}
public trubyteEntities y;
public void Insert(emp x)
{
y = new trubyteEntities();
employee insrt = convert.ConvertempToemployee(x);
y.AddObject("employees", insrt);
y.SaveChanges();
}
Here is my Client side code
private ServiceReference1.Service1Client a;
// Constructor
public MainPage()
{
InitializeComponent();
a = new ServiceReference1.Service1Client();
a.InsertCompleted+=new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(a_InsertCompleted);
textBox1.Text=e
}
private void button1_Click(object sender, RoutedEventArgs e)
{
a.InsertAsync( =>from here i dont know the procedure
//here it showing server class emp object x
}
but I dont know the next steps
what should I have to pass and how to pass
srikar1
Member
82 Points
23 Posts
Re: how to consume wcf service in windows phone app
Apr 23, 2012 06:23 AM|LINK
Create an instance of emp class and pass it to the InsertAsync method.
In the service side Insert(emp x) method add try catch block to handle the exceptions. In catch block throw instance of fault contract.
fault contracts: http://wcftutorial.net/Fault-Contract.aspx, http://msdn.microsoft.com/en-us/library/ms733721.aspx
In a_InsertCompleted check the for results as follows:
void a_InsertCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
if (e.Error != null)
{
//log error.
}
else
{
// Service call is completed with out any error.
}
}
chandana G
Member
7 Points
69 Posts
Re: how to consume wcf service in windows phone app
Apr 23, 2012 10:40 AM|LINK
can u giveme the complete solution
Peter pi - M...
Star
12871 Points
1786 Posts
Re: how to consume wcf service in windows phone app
Apr 26, 2012 02:20 AM|LINK
Here is a article about how to call WCF service operations asynchronously.
http://msdn.microsoft.com/en-us/library/ms730059.aspx#Mtps_DropDownFilterText
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework