none
Calling WCF from Windows Store app RRS feed

  • Question

  • Hi,

    i found this code on the internet  that describes how a web service should be called from a windows store app.

        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            //Create service proxy
            WcfService.Service1Client proxy = new WcfService.Service1Client();
            //Wire the proxy to a completed handler to allow the async operation to be handled
            proxy.GetCustomerCompleted += 
              new EventHandler<WcfService.GetCustomerCompletedEventArgs> (
            proxy_GetCustomerCompleted);
            //Call the service asynchronously
            proxy.GetCustomerAsync(id);
        }

        void proxy_GetCustomerCompleted(object sender, SilverlightApplication1.WcfService.GetCustomerCompletedEventArgs e)
        {
            //Bind the returned data to the DataContext
            this.DataContext = e.Result;
        }


     I don't understand this proxy.GetCustomerCompletedEventArgs arguments.
    How and where to implement it?

     Many of sample codes online has this kind of attributes but there is nowhere a description or implementation of those.

    Thanks! 

        
    • Moved by Fred Bao Tuesday, July 29, 2014 2:07 AM WCF Related
    Monday, July 28, 2014 5:43 AM

All replies

  • HI Alen,

    I moved your thread to WCF forum for better support.

    Best Regards,

    Kristin

    Tuesday, July 29, 2014 2:09 AM
  • Hi,

    By default, the methods that we have in service client in Windows Store app/Silverlight/Windows Phone are asynchronous method calls. Then since all the WCF service calls are made asynchronously, so we need an asynchronous method that starts the communication and an event which will be raised when the call completes. So the completed event has been subscribed to and then call the asynchronous method as following:

    proxy.GetCustomerCompleted += 

              new EventHandler<WcfService.GetCustomerCompletedEventArgs> ( proxy_GetCustomerCompleted);
    proxy.GetCustomerAsync(id); 

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, July 29, 2014 3:04 AM
    Moderator
  • HI Alen,

    I moved your thread to WCF forum for better support.

    Best Regards,

    Kristin

    thanks, didn't even realize
    Tuesday, July 29, 2014 11:18 AM
  • I think you didn't understand the question, maybe it's my mistake.

    It says " //Wire the proxy to a completed handler to allow the async operation to be handled"

    I don't understand how to implement this handler.

    Tuesday, August 5, 2014 8:40 AM