How much extra overhead is there when sending a file through a web service as an array of bytes?

This question shows how to send a file as a byte array through an XML web service. How much overhead is created by using this method to transfer files? I assume the data looks something like this:

<?xml version="1.0" encoding="UTF-8" ?> <bytes> <byte>16</byte> <byte>28</byte> <byte>127</byte> ... </bytes> 

If this format is correct, the bytes must first be converted to UTF-8 characters. Each of these characters allocates 8 bytes. Are bytes stored in base 10, hexadecimal or binary characters? How large is the file appearing because it is sent due to XML data and character encoding? Is compression embedded in web services?

+4
source share
5 answers

Typically, a byte array is sent as a base64 string, and not as individual bytes in tags.

http://en.wikipedia.org/wiki/Base64

The encoded version of base64 is 137% the size of the original content.

+11
source

I use this method for some internal corporate web services, and I did not notice serious slowdowns (but this does not mean that it does not exist).

You can probably use any of the many network traffic analysis tools to measure data size and make judgments based on this.

0
source

I'm not sure about all the details (compression, encoding, etc.), but I usually just use WireShark to analyze network traffic (when trying various methods), which then allows you to see exactly how it is sent.

For example, if it compressed a packet data block, it cannot be read as plain text ... however, if it is uncompressed, you will see plain old xml text ... as you would see with HTTP traffic, or even FTP in some cases.

0
source

To repeat what Kevin said in .net web services, if you have a byte array, it is by default sent as base64 encoded encoding. You can also specify the encoding of the byte array in advance.

Obviously, as soon as it gets to the server (or client), you need to manually decode the string back to the byte array, since this is not done automatically for you, unfortunately.

0
source

The main performance result will not be associated with the transfer of the encoded file, it will be in the processing that the server must do to encode the preliminary transfer of the file (if the files do not change often and the encoded version can be somehow cached).

0
source

Source: https://habr.com/ru/post/1276341/


All Articles