Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the WCF Stream object?

2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what is the WCF Stream object?" in the operation of actual cases, many people will encounter such a dilemma, and then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Because the Stream operation is limited by binding, you can only use BasicHttpBinding,NetTcpBinding and binding, so it will inevitably affect the activation type of the service instance, most importantly, the Session mode. First of all, BasicHttpBinding does not support the activation type of Session mode. NetTcpBinding and NetNamedPipeBinding bindings support Session mode, but because WCF Stream object operations do not support reliable messaging, ReliableSession cannot be set to true. Therefore, when defining the SessionMode of a service contract, you cannot set its value to SessionMode.Required, or an exception will be thrown.

WCF Stream object manipulation (meaning that TransferMode is not Buffered) does not support Session schema itself. Even if we set the SessionMode of the service contract to Allowed and the InstanceContextMode of the service to PerSession when using NetTcpBinding, the service is still executed in PerCall mode. (if it is not a Stream operation, the setting service should be in PerSession mode.) therefore, when performing a Stream operation, even if the service is set in Session mode, if we get the session ID through OperationContext.Current.SessionId, the value should be empty.

In addition, because the transferred Stream object is large and may take too long, it is recommended that you increase the value of the bound SendTimeout property. For example, set it to 10 minutes. The programming method is set to:

Binding.SendTimeout=TimeSpan.FromMinutes (10)

The configuration file is set as follows:

Note that the relevant settings for the binding must require the configuration of the server to be consistent with that of the client. * in practice, all settings are set through configuration files. For example, in my application, it is set like this:

That's all for "what is the WCF Stream object?" Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report