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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:32:17+00:00 2026-05-15T04:32:17+00:00

I was wondering if it was better in WCF to use multiple operation contracts

  • 0

I was wondering if it was better in WCF to use multiple operation contracts or to have only one operation contract with a polymorphic data contract.

Let me give you a small example :

[OperationContract]
action1Answer action1(action1data a);

[OperationContract]
action2Answer action2(action2data a);

or

[OperationContract]
actionAnswer action(actionContract a);

Action contract would be an abstract class which both action1Contract and action2Contract will inherit from. The action contract would specify the do() member function in its interface which would have in turn to be overloaded in the child classes

Personnaly I find the second approach to be more intersting as it allow you to nicely encapsulate the data and the action in the derived actionContract and in turn makes it easier to add new actions. But It’s the first time I’m using WCF so probably you know better!

  • 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-15T04:32:18+00:00Added an answer on May 15, 2026 at 4:32 am

    This question borders on the edges of the Holy Wars of OO polymorphism and SOA, but I’ll provide my two cents:

    When you’re considering developing a service layer, it should be clear to the end consumer of the service what to pass in and what to expect; approach 2 doesn’t handle that well. (Also, when doing SOAP with WCF and then loading from the wsdl in other .NET projects, it doesn’t properly mark abstract classes, nor do interfaces get transferred. WSDLs have no way of describing a non-instantiable base class, it seems.)

    Though, I must admit, I think the second process is great using the KnownTypeAttributes (as I see just now marc_s has posted) – I’ve used it myself when allowing for unknown future requirements.

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

Sidebar

Related Questions

I'm just wondering which one is better, or more recommended for processing form data.
Wondering if there is a better option than a wcf callback. When processing some
I was wondering what is better in this case? I have to read in
I have define a collection like List ids. I am wondering which is better
I'm wondering what is better in therms of performance: write in one big text
Wondering if you some better suggestions that what I have come up with. I
I am wondering what is better to do. I have a pulled back a
gcc 4.4.4 c89 Fedora 13 I am wondering what is better. To give you
I was wondering which was better: $lookup = array( a => 1, b =>
I'm wondering what a better design is for the intersection table for a many-to-many

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.