Results 1 to 2 of 2

Thread: [RESOLVED] wcf DualBinding not working

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    Resolved [RESOLVED] wcf DualBinding not working

    Hi All,

    In my Wcf Service My Service Contract is defined as follows:

    Code:
    namespace RatabaseWCFService
    {
        [ServiceContract(CallbackContract=typeof(IRatabaseXmlReturn), SessionMode = SessionMode.Required)]
        public interface IRatabaseService
        {
            [OperationContract(IsOneWay = false)]
            [FaultContract(typeof(ApplicationException))]
            void Rates(string data);
        }
    
        public interface IRatabaseXmlReturn
        {
            [OperationContract(IsOneWay = true)]
            void OnRatabaseCallback(string XmlReturn);
        }
    }
    My service is defined below and uses a background worker object. My worker_runWorkerCompleted is hit and e.Result contains the data I want to pass back up the chain.

    Code:
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
        public class RatabaseService : IRatabaseService
        {
            BackgroundWorker worker;
            private String xmlData;
            private String xmlReturn;
    
            IRatabaseXmlReturn callback;
    
            void IRatabaseService.Rates(string data)
            {
                
               // xmlData = data;
                StreamReader reader = File.OpenText("c:\\RatabaseService\\XmlTemplates\\FrozenFoods.xml");
                xmlData = reader.ReadToEnd();
                reader.Close();
    
                worker = new BackgroundWorker();
                worker.DoWork += new DoWorkEventHandler(worker_DoWork);
                worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
                worker.RunWorkerAsync();
                callback = OperationContext.Current.GetCallbackChannel<IRatabaseXmlReturn>();
     
            }
    
            void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
            {
                callback.OnRatabaseCallback(e.Result.ToString());
            }
    
             protected void worker_DoWork(object sender, DoWorkEventArgs e)
            {....
    The code that uses the service is as follows:

    Code:
    public class GRIDRatabaseService : IGRIDRatabaseService, IRatabaseServiceCallback
        {
            private static AutoResetEvent waitForResponse;
    
    public FrozenFoodsSectionRating GetFrozenFoodsSectionRate()
            {
                
                try
                {
                    waitForResponse = new AutoResetEvent(false);
                    InstanceContext callbackContext = new InstanceContext(new GRIDRatabaseService());
                    using (RatabaseService.RatabaseServiceClient RateService = new RatabaseServiceClient(callbackContext)) 
                    {
                                     
                        RateService.Open();
                        
                        RateService.Rates("myXMLDataSource");
                        waitForResponse.WaitOne();
                        
                        RateService.Close();
                    }
                    
                   
                }
                catch (FaultException<ApplicationException> e) //this will be raised by the service if there's an error in the rating engine
                {
                    throw e.Detail;
                }
                return new FrozenFoodsSectionRating();
            }
    
           public void OnRatabaseCallback(string XmlReturn)
            {
                waitForResponse.Set();
                throw new NotImplementedException();
            }
    in my client code it calls the rates method and then gets to the waitForResponse.WaitOne() but never comes back into the OnRatabaseCallback event. my endpoint bindings are declared as wsDualHttpbinding in the app.config file. can anybody see the problem?

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    Re: wcf DualBinding not working

    After looking through the Programming WCF Services book o'reilly, the first thing stated was not to use httpDualBinding as the bindint type, but instead to use tcp binding. this seemed to make it work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width