how to consume a soap web service and display the data in my windows phone application

后端 未结 2 998
广开言路
广开言路 2021-01-16 11:20

I am building my first app for windows application. My requirement is that- On clicking a button i want to navigate to another page and in that page i want the data to be di

相关标签:
2条回答
  • 2021-01-16 12:09

    You had associate the delegate but you have not called the method. You probably have a method like

    KejriwalService.arvindSoapClient.DoSomethingAsync()

    This will fire the event and after that it will trigger the client_getarvindNewsCompleted method when the responde from the WebService comes.

    Edit Just remember to use the [WebMethod] attribute in you WebService method.

    public class Service1 : System.Web.Services.WebService
    { 
        [System.Web.Services.WebMethod]
        public string getarvindNews()
        {
           return "I am a string";
        }
    }
    

    In you code you call this async like this:

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        KejriwalService.arvindSoapClient client = new arvindSoapClient();
        client.getarvindNewsCompleted += new 
            EventHandler<getarvindNewsCompletedEventArgs>(client_getarvindNewsCompleted);
    
        //Call the method async and get its result in client_getarvindNewsCompleted
        client.getarvindNewsAsync();
    }
    
    void client_getarvindNewsCompleted(object sender, getarvindNewsCompletedEventArgs e)
    {
        textBlock1.Text = e.Result.ToString();
    }
    
    0 讨论(0)
  • 2021-01-16 12:14

    Just check your web service. Your code is perfect but you need to change your web service. Donot return string from your web method but return the xml

    0 讨论(0)
提交回复
热议问题