Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6790601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:44:40+00:00 2026-05-26T17:44:40+00:00

I have one WCF service that exposes two operations – IncrementList() and GetList(). Client

  • 0

I have one WCF service that exposes two operations – IncrementList() and GetList(). Client B connects to the service, calls GetList() and displays to the user. Client A has the ability to update this list by calling IncrementList().
I want Client B to get notified when IncrementList() is called so it can call GetList() again to display the updated data.

Could you please outline how you’d implement this? CallBacks? Duplex? Publisher/Subscriber?

Anything new in WCF 4.0 that aids in this scenario?

Service diagram

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:44:41+00:00Added an answer on May 26, 2026 at 5:44 pm

    Something you should decide up front is if you want to push the whole list when its incremented (heavy) or just the updated item to each client. The code below is for push whole list but easy to modify this just to push the updated object (recomended).
    At app start Client B should call Register_client and then GetList. Subsequently it will be notified via call back when list is incremented (the client needs to implient this interface)
    The call GetList requires a duplex channel and SessionMode.Required.

    Your server should impliment:

    [ServiceContract(SessionMode = SessionMode.Required
                     CallbackContract = typeof(IMyCallback))]
        public interface IMyServer {
    
        [OperationContract]
        void Register_client();
    
        [OperationContract(IsOneWay = true)]
        void IncrementList();
    
        [OperationContract]
        ListObject[] GetList();
    }  
    
    [DataContract]
    public class ListObject {
        [DataMember]...
    }
    

    Your client should impliment:

    public interface IMyCallback {
        [OperationContract(IsOneWay = true)]
        void PushList(ListObject[] list);
    }
    

    Register client just needs store client callback interface for use when list is incremented something like:

    public override void Register_client() {
        // Store callback interfaces for all connected clients:
        IMyCallback callback = OperationContext.Current.GetCallbackChannel<IGatewayServerCallback>();
        if (clients.Contains(callback) == false)
        clients.Add(callback);
        Trace.WriteLine(string.Format("Client connection established ({0})", clients.Count));
    }
    

    Where:

    private List<IMyCallback> clients = new List<IMyCallback>();
    

    The impliementation of IncrementList should do a callback to push new list (or better just the new object that was added to list) to client – something like:

    for (int i = 0; i < clients.Count; i++) {
        if (((ICommunicationObject)clients[i]).State == CommunicationState.Opened) {
        try {
            clients[i].PushList(list);
        }
        catch (Exception e) {
            clients.RemoveAt(i--);
            Trace.WriteLine(e);
            Trace.WriteLine(string.Format("Removing client {0} (exception).", i + 1));
        }
    }
    

    The callback implimentation (client side) looks something like:

    public class MyCallback : IMyCallback {
    public void PushList(ListObject[] list) {
        // Were client side - update list code here...
    }
    

    Probably this callback implimentation needs a reference to some object that holds the list data – probably this is passed in to contructor (not shown).

    When you instantiate your proxy object you will need to pass an instance of callback to the proxy constructor – something like:

    MyServerClient client_proxy = new MyServerClient(new InstanceContext(my_callback, binding_str)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WCF Service that exposes two endpoints. One with a WebHttpBinding (acting
I have a WCF service that is returning a block of xml. One element
I have a fairly straightforward WCF service that performs one-way file synchronization for a
Here is the scenario, I have a WCF service call that takes one string
I have two Services called TemplateService, TemplateReportService (both defined in one WCF Service Library)
Here is my situation. I have written a WCF service which calls into one
The Setup I have a WCF service that exposes a base type (e.g. Animal)
I am designing a WCF service which have some operations that i expose to
I have 3 projects in the same solution - one exposes a WCF service
I have a WCF REST service that exposes a couple dozen objects and based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.