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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:08:33+00:00 2026-05-24T08:08:33+00:00

I have several WCF services in a test harness that have some similar functionality,

  • 0

I have several WCF services in a test harness that have some similar functionality, like start/stop/clean parts of distributed system under test. I cannot use a universal contract to do that – each part of the distributed system has different steps for those operations.

I was thinking to define a base interface and derive the current WCF interfaces from them.

For Example:

interface Base
{
    void BaseFoo();
    void BaseBar();
    ...
}

interface Child1:Base
{
    void ChildOperation1();
    ...
}

interface Child2:Base
{
    void ChildOperation2();
    ...
}

What I have right now is those start/stop/clean operations defined in each child interface.

Q Shall I extract similar functionality into the base interface or are there any other solutions? Will I have any problems with the inheritance of contracts in WCF?

  • 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-24T08:08:33+00:00Added an answer on May 24, 2026 at 8:08 am

    Service contract interfaces can derive from each other, enabling you to define a hierarchy
    of contracts. However, the ServiceContract attribute is not inheritable:

    [AttributeUsage(Inherited = false,...)]
    public sealed class ServiceContractAttribute : Attribute
    {...}
    

    Consequently, every level in the interface hierarchy must explicitly have the Service
    Contract attribute.

    Service-side contract hierarchy:

    [ServiceContract]
    interface ISimpleCalculator
    {
        [OperationContract]
        int Add(int arg1,int arg2);
    }
    [ServiceContract]
    interface IScientificCalculator : ISimpleCalculator
    {
        [OperationContract]
        int Multiply(int arg1,int arg2);
    }
    

    When it comes to implementing a contract hierarchy, a single service class can implement
    the entire hierarchy, just as with classic C# programming:

    class MyCalculator : IScientificCalculator
    {
        public int Add(int arg1,int arg2)
        {
            return arg1 + arg2;
        }
        public int Multiply(int arg1,int arg2)
        {
            return arg1 * arg2;
        }
    }
    

    The host can expose a single endpoint for the bottommost interface in the hierarchy:

    <service name = "MyCalculator">
        <endpoint
        address = "http://localhost:8001/MyCalculator/"
        binding = "basicHttpBinding"
        contract = "IScientificCalculator"
        />
    </service>
    

    You have not worry about contract hierarchy.

    Inspired by Juval Lowy WCF book

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

Sidebar

Related Questions

I have several WCF services that I have imported into a .Net4 Class Library.
I have several WCF services that each except several parameters. The service uses transport
I have several resources that I'd like to expose using the WCF Web API.
I have several wcf services which are hosted using ServiceHost class. Now , I
I have several old 3.5in floppy disks that I would like to backup. My
I have a WCF Service that maintains several connections to various databases. I am
I have several WCF services in an ASP.NET application. I want to prevent applications
I have created several WCF services. In order to avoid adding service references in
I have a windows service hosting several WCF services. In my windows service I
I have several WCF services and I want to execute methods in them at

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.