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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:07:25+00:00 2026-06-18T12:07:25+00:00

In WCF how to let user decide which service to request when you ask

  • 0

In WCF how to let user decide which service to request when you ask for two values and have ability to perform different calculations with those values.

For example you ask for value1 and value 2. And user have a choice to perform addition, subtraction and multiplication with those values.

How can you achieve that?

        [OperationContract]
    int GetTwoValues(int value1, int value2);

public int addition(int value1, int value2){
return value1+value2;
}

public int subtraction(int value1, int value2){
return value1-value2;
}

How to do some logic like

if user.request="addition"{
do addition
}
else if user.request="subtraction"{
do subtraction
}

i know its not a code that i have written but just trying to have you get some understanding of what i am saying. Any help will really be appreciated.

  • 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-18T12:07:26+00:00Added an answer on June 18, 2026 at 12:07 pm

    Not quite sure I understand the question

    [OperationContract]
    public int Subtraction(int value1, int value2)
    {
        return value1 - value2;
    }
    
    [OperationContract]
    public int Addition(int value1, int value2)
    {
        return value1 + value2;
    }
    

    would work as would something like

    [OperationContract]
    public int Calculation(int value1, int value2, string calcType)
    {
        switch (calcType)
        {
            case "addition":
                return value1 + value2;
            case "subtraction":
                return value1 - value2;
        }
        //return default or throw exception
    }
    

    Not that either is without drawbacks of course, but both meet your criteria.

    edit: your comment raises the obvious point that the switch case allows the user to possibly supply a value that doesn’t map.

    Yes it does and I wouldn’t use strings, that was your example!

    Possible ways round it?

    • Validate the user input – let them know when they provide something that isn’t valid
    • Use a default
    • Throw an exception
    • Use an enum to force the user to select from a pre defined list
    • Similarly use the first method

    I think perhaps you need to explain more in your question about what you want to achieve.

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

Sidebar

Related Questions

Let's say I have a WCF service which has a method returning object Person.
I have a WCF service ( Let's say WCFService1 ) is deployed on two
WCF service has one method ( Let's say TestMethod) in which I try to
I'm new to WCF. Let's say I have two asp.net apps, one that uses
I have a WCF service that has a few different responsibilities, but it provides
I have create a web service using WCF and I want to display, let's
I have a WCF service that can return several different collections. Objects in each
Let's say I have some form where user input some WCF/RIA Services URL and
Let's say I have a WCF contract such as [ServiceContract] public interface IContract {
Let's say you've got a WCF service that is accessible via HTTP and HTTPS,

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.