开发者

byte[] array size is equal to actual size of array in C#?

开发者 https://www.devze.com 2023-01-08 12:16 出处:网络
Does the byte[] array size reflects the same size of bytes to be transmitted if I need to transmit the file via a webservice?

Does the byte[] array size reflects the same size of bytes to be transmitted if I need to transmit the file via a webservice?

E.G开发者_运维百科:

byte[] testarray = new byte[100000]

means that its size if transmitted will be approx 100,000 bytes (100kB)?

thanks


Without much detail, the answer is yes. testarray is a byte buffer of 100000 count. That is 100000/1024 = 97.6 KiB (damn you kB v. KiB SI standards)


It depends what protocol you will be using for accessing the web service. If you're using SOAP over HTTP, there is going to be significant overhead, because the byte array will be transmitted as a base64 string. That would still mean an roughly a 8/6 increase in size, just over 130 kiB.

You may want to look into using MTOM. That will significantly reduce the overhead.

Another thing you may need to consider is that web service frameworks such as WCF sometimes have maximum message sizes. For the default WCF configuration, the message would be too large.


Yes, that is as long as you don't encode it differently.


Usually no, because all data has to be serialised into the appropriate format dictated by the binding or protocol that the service is using.

Different service technologies use different serialisers, WCF in particular is highly configurable. Your array could be transmitted as an XML fragment with one element per array element, a JSON string, old-style SOAP RPC format, base64 string, or whatever.

0

精彩评论

暂无评论...
验证码 换一张
取 消