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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:50:12+00:00 2026-05-23T07:50:12+00:00

I was trying to understand what goes on in the background when I write

  • 0

I was trying to understand what goes on in the background when I write the following piece of code to host a REST webservice in WCF:

RouteTable.Routes.Add(new ServiceRoute("", new WebServiceHostFactory(),
                                       typeof(MyConcreteService)));

Also, the class definition is something like this:

public class MyConcreteService : IService

where IService defines the ServiceContract and OperationContract with WebGET etc

In setting up the routes, I never mention IService anywhere. How does the server find out what contracts to use ? Can someone spell out the secret that goes on in the background which makes the webservice work ?

  • 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-23T07:50:13+00:00Added an answer on May 23, 2026 at 7:50 am

    The WebServiceHostFactory returns an instance of WebServiceHost. That class will see if the service class itself is decorated with [ServiceContract] – if so, it will use it as the contract type. Otherwise it will look for the interfaces implemented by the service class to see which ones are decorated with [ServiceContract]. If it finds only one (which is the case in your example), then it will be the one used as the contract type. If it finds 0 or more than 1, it should throw an exception.

    Having the contract type, WebServiceHost will add an endpoint with that contract type, the appropriate binding (WebHttpBinding) and an empty relative address. It will also add the appropriate behavior for web endpoints (WebHttpBehavior). That’s essentially it; it may do other things such as setting up a content type mapper if needed, etc, but the beauty of the WebServiceHost (and WebServiceHostFactory) class is that you don’t need to know about it (in most of the cases).

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

Sidebar

Related Questions

I have the following assembly code snippet I am trying to understand. It is
Trying to understand Ruby a bit better, I ran into this code surfing the
After trying to understand why client code is not rendered in a page (injected
I'm trying to understand someone else's Perl code without knowing much Perl myself. I
I am trying to understand some example code on this web page: ( http://www.csharp-station.com/HowTo/HttpWebFetch.aspx
I am trying to understand how native code can interact with .NET code and
I am trying to understand the following example, that is similar (but not equal)
Trying to understand an fft (Fast Fourier Transform) routine I'm using (stealing)(recycling) Input is
Trying to understand the options for will_paginate's paginate method: :page — REQUIRED, but defaults
Trying to understand something. I created a d:\svn\repository on my server. I committed folders

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.