Represents a binding that a Windows Communication Foundation (WCF) service can use to configure and expose endpoints that are able to communicate with ASMX-based Web services and clients and other services that conform to the WS-I Basic Profile 1.1.
<basicHttpBinding> <binding allowCookies="Boolean" bypassProxyOnLocal="Boolean" closeTimeout="TimeSpan" envelopeVersion="None/Soap11/Soap12" hostNameComparisonMode="StrongWildCard/Exact/WeakWildcard" maxBufferPoolSize="Integer" maxBufferSize="Integer" maxReceivedMessageSize="Integer" messageEncoding="Text/Mtom" name="string" openTimeout="TimeSpan" proxyAddress="URI" receiveTimeout="TimeSpan" sendTimeout="TimeSpan" textEncoding="UnicodeFffeTextEncoding/Utf16TextEncoding/Utf8TextEncoding" transferMode="Buffered/Streamed/StreamedRequest/StreamedResponse" useDefaultWebProxy="Boolean" <security mode="None/Transport/Message/TransportWithMessageCredential/TransportCredentialOnly"> <transport clientCredentialType="None/Basic/Digest/Ntlm/Windows/Certificate" proxyCredentialType="None/Basic/Digest/Ntlm/Windows" realm="string" /> <message algorithmSuite="Basic128/Basic192/Basic256/Basic128Rsa15/Basic256Rsa15/TripleDes/TripleDesRsa15/Basic128Sha256/Basic192Sha256/TripleDesSha256/Basic128Sha256Rsa15/Basic192Sha256Rsa15/Basic256Sha256Rsa15/TripleDesSha256Rsa15" clientCredentialType="UserName/Certificate"/> </security> <readerQuotas maxArrayLength="Integer" maxBytesPerRead="Integer" maxDepth="Integer" maxNameTableCharCount="Integer" maxStringContentLength="Integer" /> </binding> </basicHttpBinding>
Attributes and Elements
The following sections describe attributes, child elements, and parent elements.
A Boolean value that indicates whether the client accepts cookies and propagates them on future requests. The default is false.
A Boolean value that indicates whether to bypass the proxy server for local addresses. The default is false.
An Internet resource is local if it has a local address. A local address is one that is on same computer, the local LAN or intranet and is identified, syntactically, by the lack of a period (.) as in the URIs "http://webserver/" and "http://localhost/".
Setting this attribute determines whether endpoints configured with the BasicHttpBinding use the proxy server when accessing local resources. If this attribute is true, requests to local Internet resources do not use the proxy server. Use the host name (rather than localhost) if you want clients to go through a proxy when talking to services on the same machine when this attribute is set to true.
When this attribute is false, all Internet requests are made through the proxy server.
Specifies the version of SOAP that is used for messages that are processed by this binding. The only valid value is Soap11.
Specifies the HTTP hostname comparison mode used to parse URIs. This attribute is of type T:System.ServiceModel.HostnameComparisonMode, which indicates whether the hostname is used to reach the service when matching on the URI. The default value is F:System.ServiceModel.HostnameComparisonMode.StrongWildcard, which ignores the hostname in the match.
An integer value that specifies the maximum amount of memory that is allocated for use by the manager of the message buffers that receive messages from the channel. The default value is 524288 (0x80000) bytes.
The Buffer Manager minimizes the cost of using buffers by using a buffer pool. Buffers are required to process messages by the service when they come out of the channel. If there is not sufficient memory in the buffer pool to process the message load, the Buffer Manager must allocate additional memory from the CLR heap, which increases the garbage collection overhead. Extensive allocation from the CLR garbage heap is an indication that the buffer pool size is too small and that performance can be improved with a larger allocation by increasing the limit specified by this attribute.
An integer value that specifies the maximum size, in bytes, of a buffer that stores messages while they are processed for an endpoint configured with this binding. The default value is 65,536 bytes.
A positive integer that defines the maximum message size, in bytes, including headers, for a message that can be received on a channel configured with this binding. The sender receives a SOAP fault if the message is too large for the receiver. The receiver drops the message and creates an entry of the event in the trace log. The default is 65,536 bytes.
Defines the encoder used to encode the SOAP message. Valid values include the following:
The default is Text. This attribute is of type WSMessageEncoding.
A string that contains the configuration name of the binding. This value should be unique because it is used as an identification for the binding. Each binding has a name and namespace attribute that together uniquely identify it in the metadata of the service. In addition, this name is unique among bindings of the same type. Starting with .NET Framework 4, bindings and behaviors are not required to have a name. For more information about default configuration and nameless bindings and behaviors, see Simplified Configuration and Simplified Configuration for WCF Services.
Specifies the XML namespace of the binding. The default value is "http://tempuri.org/Bindings". Each binding has a name and namespace attribute that together uniquely identify it in the metadata of the service.
A URI that contains the address of the HTTP proxy. If useSystemWebProxy is set to true, this setting must be null. The default is null.
Sets the character set encoding to be used for emitting messages on the binding. Valid values include the following:
The default is UTF8. This attribute is of type Encoding.
A valid TransferMode value that specifies whether messages are buffered or streamed on a request or response.
A Boolean value that specifies whether the auto-configured HTTP proxy of the system should be used, if available. The default is true.
Defines the security settings for the binding. This element is of type BasicHttpSecurityElement.
Defines the constraints on the complexity of SOAP messages that can be processed by endpoints configured with this binding. This element is of type XmlDictionaryReaderQuotasElement.
This element holds a collection of standard and custom bindings.
The BasicHttpBinding uses HTTP as the transport for sending SOAP 1.1 messages. A service can use this binding to expose endpoints that conform to WS-I BP 1.1, such as those that ASMX clients consume. Similarly, a client can use the BasicHttpBinding to communicate with services exposing endpoints that conform to WS-I BP 1.1, such as ASMX Web services or services configured with the BasicHttpBinding.
Security is turned off by default, but can be added setting the mode attribute of the <security> of <basicHttpBinding> child element to a value other than None. It uses a "Text" message encoding and UTF-8 text encoding by default.
The following example demonstrates the use of BasicHttpBinding that provides HTTP communication and maximum interoperability with first- and second-generation Web services. The binding is specified in the configuration files for the client and service. The binding type is specified using the binding attribute of the <endpoint> element. If you want to configure the basic binding and change some of its settings, it is necessary to define a binding configuration. The endpoint must reference the binding configuration by name by using the bindingConfiguration attribute of the <endpoint> element, as shown in the following configuration code for the service.
<system.serviceModel> <services> <service type="Microsoft.ServiceModel.Samples.CalculatorService" behaviorConfiguration="CalculatorServiceBehavior"> <endpoint address="" binding="basicHttpBinding" bindingConfiguration="Binding1" contract="Microsoft.ServiceModel.Samples.ICalculator" /> </service> </services> <bindings> <basicHttpBinding> <binding name="Binding1" hostNameComparisonMode="StrongWildcard" receiveTimeout="00:10:00" sendTimeout="00:10:00" openTimeout="00:10:00" closeTimeout="00:10:00" maxReceivedMessageSize="65536" maxBufferSize="65536" maxBufferPoolSize="524288" transferMode="Buffered" messageEncoding="Text" textEncoding="utf-8" bypassProxyOnLocal="false" useDefaultWebProxy="true" > <security mode="None" /> </binding> </basicHttpBinding> </bindings> </system.serviceModel>
Starting with .NET Framework 4, bindings and behaviors are not required to have a name. The functionality from the previous example can be accomplished by removing the bindingConfiguration from the endpoint address and the name frm the binding.
<system.serviceModel> <services> <service type="Microsoft.ServiceModel.Samples.CalculatorService" behaviorConfiguration="CalculatorServiceBehavior"> <endpoint address="" binding="basicHttpBinding" contract="Microsoft.ServiceModel.Samples.ICalculator" /> </service> </services> <bindings> <basicHttpBinding> <binding hostNameComparisonMode="StrongWildcard" receiveTimeout="00:10:00" sendTimeout="00:10:00" openTimeout="00:10:00" closeTimeout="00:10:00" maxReceivedMessageSize="65536" maxBufferSize="65536" maxBufferPoolSize="524288" transferMode="Buffered" messageEncoding="Text" textEncoding="utf-8" bypassProxyOnLocal="false" useDefaultWebProxy="true" > <security mode="None" /> </binding> </basicHttpBinding> </bindings> </system.serviceModel>