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 7839695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:31:14+00:00 2026-06-02T15:31:14+00:00

The program I am working on exposes both callbacks and services using wcf. Basically,

  • 0

The program I am working on exposes both callbacks and services using wcf.
Basically, what the services do is simply return some variables value. As for the callback, they simply update those variables.

I want to be able to expose one class containing only the services and one class containing the services and the callbacks.

For example :

[ServiceContract]
[ServiceBehavior(InstanceContextMode=InstanceContextMode::Single, ConcurrencyMode=ConcurrencyMode::Multiple)]
public ServiceClass
{
  [OperationContract]
  public int getValue()
  {
    return mValue;
  }

  protected static int mValue;

};

[ServiceContract]
[ServiceBehavior(InstanceContextMode=InstanceContextMode::Single, ConcurrencyMode=ConcurrencyMode::Multiple)]
public ServiceAndCallbackClass : ServiceClass
{
  [OperationContract]
  public bool subscribe()
  {
    // some subscribing stuff
  }

  public void MyCallback()
  {
    ++mValue;

    // Notify every subscriber with the new value
  }

};

If I want only the services, I can use the base class. However, if I want to subscribe to the callback and use the service, I can use ServiceAndCallbackClass.

Is this possible ?

  • 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-06-02T15:31:16+00:00Added an answer on June 2, 2026 at 3:31 pm

    One solution I found :

    Make 2 interfaces. The first one containing only the services and the second one inheriting from the first one and adding the callbacks.

    An implementation class would implement the 2 interfaces.

    Example :

    [ServiceContract]
    [ServiceKnownType(typeof(ICallback))]
    public interface IService
    {
      [OperationContract]
      int GetData();
    }
    
    [ServiceContract]
    public interface ICallback : IService
    {
      [OperationContract]
      public bool subscribe();
    }
    
    [ServiceBehavior(InstanceContextMode=InstanceContextMode::Single, ConcurrencyMode=ConcurrencyMode::Multiple)]
    public ServiceClass : IService, ICallback
    {
      public int getValue()
      {
        return mValue;
      }
    
      public bool subscribe()
      {
        // some subscribing stuff
      }
    
      public void myCallback()
      {
        ++mValue;
    
        // Notify every subscriber with the new value
      }    
    
      protected static int;
    };
    
    [ServiceBehavior(InstanceContextMode=InstanceContextMode::Single, ConcurrencyMode=ConcurrencyMode::Multiple)]
    public ServiceAndCallbackClass : ServiceClass
    {
      // Dummy implementation used to create second service
    };
    

    From there, we can create 2 services. One based on the implementation class and one based on the “Dummy” class. Each service would be created from a different interface and thus exposing different methods.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've a program working as client and server. I'm using wcf services with BasicHttpBinding
I am using Junit 4. My whole program is working fine. I am trying
I am working on adding a phong shader to my working program. Basically, after
I am generating the xml file using the DOM and the program is working
I had a program working with a database I created using SQL Server Compact
Background: I am writing a C++ program working with large amounts of geodata, and
how can i make java program working with multiple languages (frensh, english , arabic
Having successfully gotten a sample program working, I'm now starting to do Real Work
I'm trying to get a simple winsock program working, so I create my socket
I'm trying to get a helloworld type program working with REST CI/jquery. I've included

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.