locked
How to create async interface in WCF service to use with a Silverlight client? RRS feed

  • Question

  • User-493262165 posted

    I am having difficulty with transforming my synchronous WCF Service design to an asynchronous one that my Silverlight client can use.  Here's an import of my IMyWCFService.cs file:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.Serialization;
    using System.ServiceModel;
    using System.Text;
    
    namespace MyWCFService
    {
        // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IMyWCFService" in both code and config file together.
        [ServiceContract]
        public interface IMyWCFService
        {
            [OperationContract(AsyncPattern = true)]
            //string SayHello(String name);
            IAsyncResult BeginSayHello(String name, AsyncCallback cb, Object state);
    
            string EndSayHello(IAsyncResult result);
    
            [OperationContract(AsyncPattern = true)]
            //int ComputeY(int m, int x, int b);
            IAsyncResult BeginComputeY(int m, int x, int b, AsyncCallback cb, Object state);
    
            string EndBeginComputeY(IAsyncResult result);
    
        }
    }

    And here is the code in my MyWCFService.svc.cs file:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.Serialization;
    using System.ServiceModel;
    using System.Text;
    
    namespace MyWCFService
    {
        // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "MyWCFService" in code, svc and config file together.
        public class MyWCFService : IMyWCFService
        {
            public string SayHello(String name)
            {
                return "Hello " + name;
            }
    
            public IAsyncResult BeginSayhello(String name, AsyncCallback cb, Object state)
            {
                Console.WriteLine("BeginSayHello called with: " + name);
                return new CompletedAsyncResult<string>(name);
            }
    
            public int ComputeY(int m, int x, int b)
            {
                return (m * x) + b;
            }
        }
    }

    These are the error messages that I am getting right now, and I don' know how to get around them:

    c:\users\a0171964\documents\visual studio 2010\Projects\MyWCFService\MyWCFService\MyWCFService.svc.cs(11,18): error CS0535: 'MyWCFService.MyWCFService' does not implement interface member 'MyWCFService.IMyWCFService.BeginSayHello(string, System.AsyncCallback, object)'
    c:\users\a0171964\documents\visual studio 2010\Projects\MyWCFService\MyWCFService\IMyWCFService.cs(16,22): (Related location)
    c:\users\a0171964\documents\visual studio 2010\Projects\MyWCFService\MyWCFService\MyWCFService.svc.cs(11,18): error CS0535: 'MyWCFService.MyWCFService' does not implement interface member 'MyWCFService.IMyWCFService.EndSayHello(System.IAsyncResult)'
    c:\users\a0171964\documents\visual studio 2010\Projects\MyWCFService\MyWCFService\IMyWCFService.cs(18,16): (Related location)
    c:\users\a0171964\documents\visual studio 2010\Projects\MyWCFService\MyWCFService\MyWCFService.svc.cs(11,18): error CS0535: 'MyWCFService.MyWCFService' does not implement interface member 'MyWCFService.IMyWCFService.BeginComputeY(int, int, int, System.AsyncCallback, object)'
    c:\users\a0171964\documents\visual studio 2010\Projects\MyWCFService\MyWCFService\IMyWCFService.cs(22,22): (Related location)
    c:\users\a0171964\documents\visual studio 2010\Projects\MyWCFService\MyWCFService\MyWCFService.svc.cs(11,18): error CS0535: 'MyWCFService.MyWCFService' does not implement interface member 'MyWCFService.IMyWCFService.EndBeginComputeY(System.IAsyncResult)'
    c:\users\a0171964\documents\visual studio 2010\Projects\MyWCFService\MyWCFService\IMyWCFService.cs(24,16): (Related location)
    
    Compile complete -- 4 errors, 0 warnings
    

    Can anyone please shed some light on what I am doing wrong at this point?  I'm at a standstill right now -- I can't find any examples on the net to help me get around these errors.

    -Bob


    Monday, February 18, 2013 2:59 PM

Answers

All replies