how to consume wcf service in windows phone app

Domanda how to consume wcf service in windows phone app

  • martedì 10 aprile 2012 10:04
     
     

    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(
      //here it showing server class emp 
            }

    but I dont know the next steps

    what should I have to pass and how to pass


    srujanna

Tutte le risposte