WSHttpBinding in WCF

The WSHttpBinding offers a lot more functionality in the area of interoperability. Unlike BasicHttpBinding, WSHttpBinding supports WS-* functionality and distributed transactions with reliable and secure sessions using SOAP security. It uses the HTTP and HTTPS transport for communication as well. This option is the best for those developers looking for this level of WS-* interoperability.

WSHttpBinding Properties

The following table shows a list of attributes, and their descriptions, that are available to be used with the WSHttpBinding.

Attribute Description
allowCookies Boolean value, default of False, which specifies whether or not the client accepts cookies and to propagate them of any future requests.
bypassProxyOnLocal Boolean value, default of False, which specifies whether or not to bypass the proxy server for local Internet resources.
closeTimeout A time interval value, which must be greater than zero, that specifies the amount of time for a close operation to complete. The default value is 1 minute (00:01:00).
hostnameComparisonMode Specifies the HTTP hostname comparison node used to parse URIs. Acceptable values are Exact, StrongWildCard, and WeakWildCard. The default value is StrongWildCard.
maxBufferPoolSize Specifies the maximum buffer size for a buffer pool, which stores messages processed by the binding. This is an integer value with a default of 512*1024, or 524388.
maxReceivedMessageSize Specifies the maximum size of a message, including headers. The number is specified in bytes with a default value of 65536. If a message is larger than the value specified, the sender receives a SOAP fault message and the receiver drops the message and creates an event in the trace log.
messageEncoding Defines the type of encoding used to encode the message. Acceptable values are Text (text encoding) and Mtom (Message Transmission Organization Mechanism 1.0 encoder). Default is Text.
Name A unique string value that contains the configuration name of the binding.
openTimeout A time interval value that specifies the amount of time a message has to complete. Value should be greater than zero. Default is 1 minute (00:01:00).
proxyAddress Used in conjunction with the useDefaultWebProxy attribute. This attribute is a URI that specifies the address of the HTTP proxy. If the useDefaultWebProxy attribute is set to True, this value must be null.
receiveTimeout A time interval value that specifies the amount of time a receive operation has to complete. Value should be greater than zero. Default is 1 minute (00:01:00).
sendTimeout A time interval value that specifies the amount of time a send operation has to complete. Value should be greater than zero. Default is 1 minute (00:01:00).
textEncoding Specifies the character encoding set. Acceptable values are UnicodeFffeTextEncoding,
Utf16TextEncoding, and Utf8TextEncoding. Default is Utf8TextEncoding. This value is used for emitting binding messages.
transactionFlow Boolean value, default of False, which specifies whether the binding supports flowing WS-Transactions.
useDefaultWebProxy Boolean value, default of True, which specifies whether the autoconfigured HTTP proxy should be used if one exists.

The following example illustrates some of the properties being configured in a configuration file:

<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name = “wshttpbind” allowcookies = “true” textencoding = “utf-8” closeTimeout = “00:00:30” receiveTimeout = “00:00:30”>
</binding>
</wsHttpBinding>
</bindings>
</system.ServiceModel>

The same can be done through code, as illustrated here:

WSHttpBinding wsb = new WSHttpBinding();
wsb.AllowCookies = true;
wsb.TextEncoding = UTF-8;
wsb.ReceiveTimeout = 30000;
wsb.CloseTimeout= 30000;
Tagged . Bookmark the permalink.

Leave a Reply