Sunday, July 21, 2013

Access Soap Web Service in Windows Phone

Accessing XML Webservice in WP 7 or Wp 8: 

Step 1: 

You have to add service reference in your code by right clicking on the reference in server explorer in Visual Studio and add your service url.
Give a name to your Service here I gave : FWebService

Step 2: 

Here is a code to access Soap web service on button click :

private void button1_Click(object sender, RoutedEventArgs e)
        {
            FWebService.Service1SoapClient client = new FWebService.Service1SoapClient();
            client.checkLoginCompleted += new EventHandler<FWebService.checkLoginCompletedEventArgs>(client_checkLoginCompleted);
            client.checkLoginAsync(textBox1.Text,textBox2.Text);
        }

        void client_checkLoginCompleted(object sender, FWebService.checkLoginCompletedEventArgs e)
        {
            if (e.Result == 1)
            {
                MessageBox.Show("Login Successfull");
            }
            else if (e.Result == 0)
            {
                MessageBox.Show("Login not successfull");
            }
           
        }