locked
Request/Reply WCF service call in between Duplex Service call RRS feed

  • Question

  • Hi,

    I want to call a WCF service method in the Duplex way and before the Duplex service calls the client, I want to call another service method in the request/reply way. Is it possible at all? Is there any sample of this kind is available?

    Thanks in advance.

    Regards

    ronit_rc

     

     

     

     

     

    Wednesday, February 1, 2012 9:38 AM

All replies

  • Hello, this is possible, and actually nothing special needs to be done. You can find a duplex sample on http://msdn.microsoft.com/en-us/library/ms731064.aspx. Inside the service implementation, you simply do not invoke the client callback until the remote service returns.
    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
    If you have feedback about forum business, please contact msdnmg@microsoft.com. But please do not ask technical questions in the email.
    Wednesday, February 1, 2012 11:37 AM
  •  


    Hi,

    Thanks for the answer.

    I think, I couldn't explain the requirement. I want a WCF service which will have two endpoints. One using "wsDualHttpBinding" and another using "wsHttpBinding". From the client, first I will call the the service method which has been exposed using "wsDualHttpBinding". Since this method is time consuming, rather than wait for the service to call client, I will call an another service method which has been exposed using "wsHttpBinding", in request/reply way . The duplex service will inform the client once it is done with it's execution. How I can approach for this kind of application.   Also, How I can call two services(Duplex and Request/Reply) simultaneously from client? Do I need to make the calls using threads?

    Is there any sample available.

    Thanks in advance.

    Regards

    ronit_rc

     


    • Edited by ronit_rc Thursday, February 2, 2012 4:57 AM
    Wednesday, February 1, 2012 11:50 AM
  • So you mean you want to call another service from the client? This is also supported, and nothing special needs to be done. When you call the duplex service, the client won't wait until the duplex service calls back the client. Instead, the client continues to run, and can do whatever you like (such as invoke another non-duplex service). When the duplex service wants to notify the client, the client's callback method will be invoked.

    If you do everything synchronously on a single thread, the result will be: If the duplex service tries to notify the client before the other service returns, the callback method won't be invoked until the other service returns. If you don't want this behavior, call the services asynchronously.


    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
    If you have feedback about forum business, please contact msdnmg@microsoft.com. But please do not ask technical questions in the email.
    Friday, February 3, 2012 1:18 AM
  •  

    Hi,

    Thanks for the answer. You got the requirement right. Only one thing, rather than calling the non-duplex from another service, I have exposed it in an "wsHttpEndpoint" endpoint of the same service. I think I have to call the service methods asynchronously. So I have called them as following:

    InstanceContext iContext = new InstanceContext(new Callback());
    ServiceClient Client1= new ServiceClient (iContext,"WSDualHttpBinding_IService1");
    Client1.Method1()

    ChannelFactory<IService2> factory = new ChannelFactory<IService2>("WSHttpBinding_IService2", new EndpointAddress("http://localhost:3912/Service.svc"));
     IService2 Client2= factory.CreateChannel();

    ThreadPool.QueueUserWorkItem((o) =>
                {
                    Thread.Sleep(5000);
                    Client2.Method2();
                 
                });

    After the above implementation, I have observed, the call to second service method is not being made unless the duplex service is calling the client. This is not expected. Also, the Non-Duplex service call is throwing an error as following:

    "The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error".

    Could you please help me on this?

    Regards

    ronit_rc

    Friday, February 3, 2012 6:13 AM