How to call the web service methods in Windows Phone 7?

advertisements

For connecting to webservices i wrote the following code.

WebClient wc = new WebClient();
wc.DownloadStringAsync(new Uri("http://www.Webservices.asmx"));
wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);

void wc_DownloadStringCompleted(object sender,DownloadStringCompletedEventArgs e)
{
    Debug.WriteLine("Web service says: " + e.Result);
    using (var reader = new StringReader(e.Result))
    {
        String str = reader.ReadToEnd();
    }
}

by using above code Get the string result.But i want get the result in HTMLVisulaizer then i know the what are the methods having that webservice.then i can easily access the particular method. Please tell me how to call a web service method in Windows phone 7?in webservice i am having 5 webmethods.how to get that and how to call the Particular webmenthod.

Please tell me thanks in advance.


@Jason James

The first step:

You must add referent Services ,like Jason James has very detailed instructions .

step 2 :

You can open App.xaml.cs , in Functions Apps

public Apps()
{
    // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Show graphics profiling information while debugging.
            if (System.Diagnostics.Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are being GPU accelerated with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;
             }
           // You can declare objects here that you will use
           //Examlpe: NameservicesReferent.(Function that returns services) = new NameservicesReferent.(Function that returns services)();

Ws_Function = new Nameservices.ServiceSoapClient();

}

step 3:

in Mainpage.xaml.cs

GlobalVariables.Ws_advertise.getLinkAdvertiseIndexCompleted += new EventHandler<advertise.getLinkAdvertiseIndexCompletedEventArgs>(Ws_advertise_getLinkAdvertiseIndexCompleted);
GlobalVariables.***NameWedservise***.getLinkAdvertiseIndexAsync("**parameters to be passed**");

step 4:

void Ws_advertise_getLinkAdvertiseIndexCompleted(object sender, advertise.getLinkAdvertiseIndexCompletedEventArgs e)
        {
             //function returns the results to you, the example here is an array
           string[] array = null;
           try

           {
              array = e.result;
              if(array != null)

           }
           cath(exception ex)
           {

           }
           finally
           {
             array = null;
GlobalVariables.Ws_advertise.getLinkAdvertiseIndexCompleted -= new EventHandler<advertise.getLinkAdvertiseIndexCompletedEventArgs>(Ws_advertise_getLinkAdvertiseIndexCompleted);
           }
         }