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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:48:20+00:00 2026-05-27T08:48:20+00:00

I am calling a web-service with POST and receiving a 2MB xml. The problem

  • 0

I am calling a web-service with POST and receiving a 2MB xml.
The problem is that it takes to much time until i can use the data within the Stream.
The response seems to be after 7 secs there, but it takes another 10 sec to read the content(its a string) from response stream.

Stopwatch s = new Stopwatch();

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(MyUri);
req.Method = "POST";

req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = Poststring.Length;
s.Start();
StreamWriter swriter = new StreamWriter(req.GetRequestStream());
swriter.Write(Poststring);
swriter.Close();

// Get the response. 7 sec
HttpWebResponse response = (HttpWebResponse)req.GetResponse();
s.Stop();
Debug.WriteLine("Talking to Web-Service: "+s.ElapsedMilliseconds);

s.Reset(); 
// Get the stream containing content returned by the server.
Stream dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);

// Read the content.  10 sec
XmlReader xmlReader = XmlReader.Create(dataStream);
s.Start();
XDocument xdoc = XDocument.Load(xmlReader);
s.Stop(); 
Debug.WriteLine("Convert stream to some useful data: "+s.ElapsedMilliseconds);

output in milliseconds

Talking to Web-Service: 6595
"Convert" stream to some useful data: 10772

Why does it take like 10 sec to read the content??
Is there stil some communication with the web-service or waiting for data when content is read? Its just a simple textfile (xml) with about 2MB. I thought that those 2 MB were transfered within the 6596 milliseconds. Because when i call that service with my browser, the xml content is shown in 6-7 sec.

The time for Talking to Web-Service is ok, but what is going on in those 10772 milliseconds?

Edit: The problem is stil there. I get different answers and they contradict each other.

  • 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-27T08:48:20+00:00Added an answer on May 27, 2026 at 8:48 am

    Add following

    httpWebRequest.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate");
    httpWebRequest.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
    

    resulting in:

    Talking to Web-Service: 6595
    "Convert" stream to some useful data: 256
    

    Now i have the same performance like in a browser!

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

Sidebar

Related Questions

I have a problem regarding xml calling to REST web service, I have to
I'm calling a web service that returns an array of objects in JSON. I
I am calling a web service to return XML data for states/provinces of countries.
My superior once told me that a bad way of calling a web service
I have a asp.net web-service which I use from my ASP.NET website. I can
I am calling a json web service that sends error messages by setting StatusCode
I am calling an ASP.net application that has an exposed JSON web service interface.
I am investigating a problem calling a web service from AJAX, which intermittently faults
Visual Studio makes calling a web service easy, trying to figure out what is
I am calling a web service from a C# forms based app. ServReturnType obj

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.