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

The Archive Base Latest Questions

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

I’ve began to learn WCF and wish to understand its internals by creating a

  • 0

I’ve began to learn WCF and wish to understand its internals by creating a simple Web server using channel stacks directly. I have found a lot of theory in the web but I’d like to see a working sample code of receiving and responding an httprequest that I can test using any browser.
I’m hoping for something that shows the setup of a custom binding by assembling binding elements all the way to responding the request.

  • 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-15T15:17:08+00:00Added an answer on May 15, 2026 at 3:17 pm

    Got the answer in MSDN forums :

    static void RunService()
        {
          //Step1: Create a custom binding with just TCP.
          BindingElement[] bindingElements = new BindingElement[2];
          bindingElements[0] = new WebMessageEncodingBindingElement();
          bindingElements[1] = new HttpTransportBindingElement();
    
          CustomBinding binding = new CustomBinding(bindingElements);
    
    
          //Step2: Use the binding to build the channel listener.     
          IChannelListener<IReplyChannel> listener =
             binding.BuildChannelListener<IReplyChannel>(new Uri("http://localhost:8080/channelapp"),
              new BindingParameterCollection());
    
          //Step3: Listening for messages.
          listener.Open();
          Console.WriteLine(
              "Listening for incoming channel connections");
    
          //Wait for and accept incoming connections.
          IReplyChannel channel = listener.AcceptChannel();
          Console.WriteLine("Channel accepted. Listening for messages");
    
          //Open the accepted channel.
          channel.Open();
    
          //Wait for and receive a message from the channel.
          RequestContext request= channel.ReceiveRequest();
    
          //Step4: Reading the request message.
          Message message = request.RequestMessage;
          Console.WriteLine("Message received");
          Console.WriteLine("To: {0}", message.Headers.To); // TO contains URL from the browser including query string  
          if (!message.IsEmpty) // HTTP GET does not contain body
          {
            string data = message.GetBody<string>();
            Console.WriteLine("Message content: {0}", data);
          }
    
          //Send a reply - You can control reply content based on message.Header.To or by message content
          Message replymessage = Message.CreateMessage(binding.MessageVersion, 
            "http://contoso.com/someotheraction", XElement.Parse("<html><body><h1>Hello</h1></body></html>"));
    
          // Set reply content type
          HttpResponseMessageProperty property = new HttpResponseMessageProperty();
          property.Headers[System.Net.HttpResponseHeader.ContentType] = "text/html; charset=utf-8";
          replymessage.Properties[HttpResponseMessageProperty.Name] = property;
    
          request.Reply(replymessage);
    
          //Step5: Closing objects.
          //Do not forget to close the message.
          message.Close();
          //Do not forget to close RequestContext.
          request.Close();
          //Do not forget to close channels.
          channel.Close();
          //Do not forget to close listeners.
          listener.Close();
        }
    

    (http://social.msdn.microsoft.com/Forums/en/wcf/thread/09b620e0-ea81-4a6c-8a10-02a032ccd821)

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am doing a simple coin flipping experiment for class that involves flipping a

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.