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

  • SEARCH
  • Home
  • 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 7898941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:34:19+00:00 2026-06-03T08:34:19+00:00

Suppose I have this simple contract which I’ve taken from MS examples and altered

  • 0

Suppose I have this simple contract which I’ve taken from MS examples and altered a bit:

  [ServiceContract(SessionMode = SessionMode.Allowed)]
        public interface IService
        {
            [WebInvoke(Method = "POST", UriTemplate = "", ResponseFormat = WebMessageFormat.Xml,
                RequestFormat = WebMessageFormat.Xml),
             Description(
                 "Adds a customer to customers collection. The response Location header contains a URL to the added item.")]
            [OperationContract]
            Customer AddCustomer(Customer customer);

            [WebInvoke(Method = "DELETE", UriTemplate = "{id}"),
             Description(
                 "Deletes the specified customer from customers collection. Returns NotFound if there is no such customer.")
            ]
            [OperationContract]
            void DeleteCustomer(string id);

            [WebGet(UriTemplate = "{id}"),
             Description(
                 "Returns the specified customer from customers collection. Returns NotFo`enter code here`und if there is no such customer.")
            ]
            [OperationContract]
            Customer GetCustomer(string id);

            [WebGet(UriTemplate = ""), Description("Returns all the customers in the customers collection.")]
            [OperationContract]
            List<Customer> GetCustomers();

            [WebInvoke(Method = "PUT", UriTemplate = "{id}"),
             Description("Updates the specified customer. Returns NotFound if there is no such customer.")]
            [OperationContract]
            Customer UpdateCustomer(string id, Customer newCustomer);
        }

I need this contract to expose over webhttp REST and over nettcp binding (with sessions).

My case(contract) is much harder, so I need to understand whether to have one implementation for both purposes and differentiate somehow between webhttpbinding call or nettcpbinding call or provide different realizations for each endpoint.

Thanks in advance

  • 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-03T08:34:21+00:00Added an answer on June 3, 2026 at 8:34 am

    I think you do not need to mix different architectural styles – SOAP/WS-* (nettcpbinding) and REST. With correct implementation they have differences. And when you will be mixing such styles in one service, logic for your services methods will contain definitely multiple if-than or switch cases to determine in which mode you are working, also that could be problems when working both with HTTP or WCF contexts.

    I suggest you to create to separate endpoints(contract) – one for REST and one for WS-*/SOAP and follow their architectural styles.

    To share logic between them, encapsulate your business logic in separate layer (classes) and then you can simply reuse it without mixing REST or WS-* specific logic and your business logic.

    When dealing with simple CRUD operations, consider to use WCF Data Serivces, that could generate REST/OData endpoints for you based on database.

    UPD from comment:
    You can work with stateless REST service but “emulate” your session. As example, it’s common to pass user authentication result token in special ‘Authentication’ HTTP header in each request to recognize and differ users. Such header is passed with each request and actually emulates session with authorized user. So, when session is only one reason for two endpoints, than this problem could be resolved with only one of them.

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

Sidebar

Related Questions

Suppose I have this sort of HTML from which I need to select text2
I have this simple activity which suppose to change the text of TextView once
Suppose you have a simple class like this: class foo{ private: int* mData; int
I have this simple Select box that is suppose to store the selected value
Let's suppose I have this this simple button: { xtype :'button', text :'button', id:'address'+counter.no,
Suppose I have this simple app working : # model class Project has_many :numbers
Suppose I have this simple class: class Color attr_accessor :rgb def initialize(ary) @rgb =
i have this class called MemoryManager, it is supposed to implement a simple smart
Suppose I have this class: class Int{ private: int x; public: Int(int i) :
Suppose I have this function, in pseudo-code, that reverse a list: def function reverse(

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.