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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:25:56+00:00 2026-05-14T03:25:56+00:00

HI I have an xml file with 500KB size which i need to send

  • 0

HI

I have an xml file with 500KB size which i need to send it to webservice, so i want to compress this data and send it to the webservice

i have heard of some base24Encoding something…
Can anyone throw more light on this

Suppose if i use GZipStream how can i send the file to the webservice

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-05-14T03:25:56+00:00Added an answer on May 14, 2026 at 3:25 am

    Something like below (the first part just writes some random xml for us to work with). Your web-service would ideally take a byte[] argument, and would have (if using WSE3 or MCF over basic-http) MTOM enabled, which reduces the base-64 overhead. You just post it the byte[] and then reverse the compression at the other end.

        if (File.Exists("my.xml")) File.Delete("my.xml");
        using (XmlWriter xmlFile = XmlWriter.Create("my.xml")) {
            Random rand = new Random();
            xmlFile.WriteStartElement("xml");
            for (int i = 0; i < 1000; i++) {
                xmlFile.WriteElementString("add", rand.Next().ToString());
            }
            xmlFile.WriteEndElement();
            xmlFile.Close();
        }
        // now we have some xml!
        using (MemoryStream ms = new MemoryStream()) {
            int origBytes = 0;
            using (GZipStream zip = new GZipStream(ms, CompressionMode.Compress, true))
            using (FileStream file = File.OpenRead("my.xml")) {
                byte[] buffer = new byte[2048];
                int bytes;
                while ((bytes = file.Read(buffer, 0, buffer.Length)) > 0) {
                    zip.Write(buffer, 0, bytes);
                    origBytes += bytes;
                }
            }
            byte[] blob = ms.ToArray();
            string asBase64 = Convert.ToBase64String(blob);
            Console.WriteLine("Original: " + origBytes);
            Console.WriteLine("Raw: " + blob.Length);
            Console.WriteLine("Base64: " + asBase64.Length);
        }
    

    Alternatively, consider a different serialization format; there are dense binary protocols that are much smaller (and as a consequence don’t benefit from gzip etc). For example, serializing via protobuf-net would give you a very efficient size. But this only applies to an object-model, not to arbitrary xml data.

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

Sidebar

Related Questions

i have xml file which contains lots of data. now i want to pick
i have xml file which contains some details i want to pick some value
I have XML file (output of some application) like this: <data> <call function=get_user_data> <output>
i want parse xml file, which does't have xml extension, like this: http://bizonek.wrzuta.pl/xml/plik/1ANdXCgTOit/unknow/undefined/643/ my
i have xml file which contains CDATA i need to update the CDATA as
I have xml-file. I need to read it, make some changes and write new
I have xml file with collection image urls and I want upload this url
I have XML file which looks like this: <?xml version=1.0?> <results> <row id=100><name>name blah</name></row>
I need to cache some xml from a webservice to a local xml file
I have an xml file stored on my website that looks like this: <games>

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.