Large binary over asmx web service

强颜欢笑 提交于 2019-12-12 14:22:27

问题


I am transfering a large zipped text file over the classic asmx web service. My reason for doing so is that the file's size is 20 MB unzipped, 4MB zipped.

This is the method. I will provide additional information if necessary.

    [WebMethod]
    public byte[] Transfer()
    {
        return File.ReadAllBytes(@"4MBFile.zip");
    }

I am using C# and .NET 4. (I changed the initial settings for the project from 2.0 to 4.0).

A webmethod uses a kind of serialization so I guess there will be some overhead.

Am i really transferring only 4MB? How do I measure this overhead, if there is any?


回答1:


XML Web Services expose useful functionality to Web users through a standard Web protocol. In most cases, the protocol used is SOAP.

This question shows that the XmlSerializer, used by ASMX Web Services, by default Base64-encodes binary data , so yes, the overhead will be noticable.

Am I really transfering only 4MB?

What keeps you from monitoring a service call using Fiddler? It'll tell the exact HTTP response body size.

There seems to be a solution by attributing the property as hexBinary, so it won't be Base64-encoded.



来源:https://stackoverflow.com/questions/12708119/large-binary-over-asmx-web-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!