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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:53:11+00:00 2026-05-26T05:53:11+00:00

I am working on a project that will receive HTTP POSTs which contain XML

  • 0

I am working on a project that will receive HTTP POSTs which contain XML data. I am going to set up HttpListener to receive HTTP POST and then response with ACK.

I am wondering if there are any examples that implement similar functionality? And how many requests could HttpListener handle in the same time?

I will have a message queue to store the requests from the client. And I will have to set up a test client to send the request to the HttpListener for testing purposes. Should I set up a WebRequest or something else to test HttpListener?

  • 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-26T05:53:12+00:00Added an answer on May 26, 2026 at 5:53 am

    You can use HttpListener to process incoming HTTP POSTs, you can pretty much follow any tutorial you find for the listener. Here is how I am doing it (note this is syncronous, to handle more than 1 request at a time, you will want to use threads or at least the async methods.)

    public void RunServer()
    {
        var prefix = "http://*:4333/";
        HttpListener listener = new HttpListener();
        listener.Prefixes.Add(prefix);
        try
        {
            listener.Start();
        }
        catch (HttpListenerException hlex)
        {
            return;
        }
        while (listener.IsListening)
        {
            var context = listener.GetContext();
            ProcessRequest(context);
        }
        listener.Close();
    }
    
    private void ProcessRequest(HttpListenerContext context) 
    {
        // Get the data from the HTTP stream
        var body = new StreamReader(context.Request.InputStream).ReadToEnd();
    
        byte[] b = Encoding.UTF8.GetBytes("ACK");
        context.Response.StatusCode = 200;
        context.Response.KeepAlive = false;
        context.Response.ContentLength64 = b.Length;
    
        var output = context.Response.OutputStream;
        output.Write(b, 0, b.Length);
        context.Response.Close();
    }
    

    The main part that gets the XML from the request is this line:

    var body = new StreamReader(context.Request.InputStream).ReadToEnd();
    

    This give you the body of the HTTP request, which should contain your XML. You could probably send it straight into any XML library that can read from a stream, but be sure to watch for exceptions if a stray HTTP request also gets sent to your server.

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

Sidebar

Related Questions

I am going to be working on a project that will heavily involve indexing
I´m working on a project that basically will show some data collected from hardware
I'm new to Speech Recognition, and I'm working on a project that will receive
I'm working on an iPhone project that needs to receive data from a PHP
I'm working on a Swing based project that will display large amounts of data
I'm working on a project that will be distributed with GNU autoconf/automake, and I
I am working on a project that will require internationalisation support down the track.
I'm working on a project that will require me to implement a calendar. I'm
I'm working on a project that will require me to take various .vbproj and
I'm working on a project that will have a single table holding lots and

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.