BasicHttpBinding Class
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Represents a binding that a Silverlight 5 client can use to configure endpoints that can communicate with ASMX-based Web services and other services that conform to the WS-I Basic Profile 1.1.
Inheritance Hierarchy
System.Object
System.ServiceModel.Channels.Binding
System.ServiceModel.BasicHttpBinding
Namespace: System.ServiceModel
Assembly: System.ServiceModel (in System.ServiceModel.dll)
Syntax
'Declaration
Public Class BasicHttpBinding _
Inherits Binding
public class BasicHttpBinding : Binding
The BasicHttpBinding type exposes the following members.
Constructors
Name | Description | |
---|---|---|
BasicHttpBinding() | Initializes a new instance of the BasicHttpBinding class. | |
BasicHttpBinding(BasicHttpSecurityMode) | Initializes a new instance of the BasicHttpBinding class with a specified type of security used by the binding. |
Top
Properties
Name | Description | |
---|---|---|
CloseTimeout | Gets or sets the interval of time provided for a connection to close before the transport raises an exception. (Inherited from Binding.) | |
EnableHttpCookieContainer | Gets or sets a value that indicates whether the [T:P:System.ServiceModel.BasicHttpBinding] will include the HttpCookieContainerBindingElement. | |
EnvelopeVersion | Gets the version of SOAP that is used for messages that are processed by this binding. | |
MaxBufferSize | Gets or sets the maximum size for a buffer that receives messages from the channel. | |
MaxReceivedMessageSize | Gets or sets the maximum size for a message that can be received on a channel configured with this binding. | |
MessageVersion | Gets the message version used by clients and services configured with the binding. (Inherited from Binding.) | |
Name | Gets or sets the name of the binding. (Inherited from Binding.) | |
Namespace | Gets or sets the XML namespace of the binding. (Inherited from Binding.) | |
OpenTimeout | Gets or sets the interval of time provided for a connection to open before the transport raises an exception. (Inherited from Binding.) | |
ReceiveTimeout | Gets or sets the interval of time that a connection can remain inactive, during which no application messages are received, before it is dropped. (Inherited from Binding.) | |
Scheme | Gets the URI transport scheme for the channels and listeners that are configured with this binding. (Overrides Binding.Scheme.) | |
Security | Gets the type of security used with this binding. | |
SendTimeout | Gets or sets the interval of time provided for a write operation to complete before the transport raises an exception. (Inherited from Binding.) | |
TextEncoding | Gets or sets the character encoding that is used for the message text. | |
TransferMode | Gets or sets a value that indicates whether messages are sent buffered or streamed. |
Top
Methods
Name | Description | |
---|---|---|
BuildChannelFactory<TChannel>(BindingParameterCollection) | Builds the channel factory stack on the client that creates a specified type of channel and that satisfies the features specified by a collection of binding parameters. (Inherited from Binding.) | |
BuildChannelFactory<TChannel>(array<Object[]) | Builds the channel factory stack on the client that creates a specified type of channel and that satisfies the features specified by an object array. (Inherited from Binding.) | |
CanBuildChannelFactory<TChannel>(BindingParameterCollection) | Returns a value that indicates whether the current binding can build a channel factory stack on the client that satisfies the collection of binding parameters specified. (Inherited from Binding.) | |
CanBuildChannelFactory<TChannel>(array<Object[]) | Returns a value that indicates whether the current binding can build a channel factory stack on the client that satisfies the requirements specified by an object array. (Inherited from Binding.) | |
CreateBindingElements | Returns an ordered collection of binding elements contained in the current binding. (Overrides Binding.CreateBindingElements().) | |
Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetProperty<T> | Returns a typed object requested, if present, from the appropriate layer in the binding stack. (Inherited from Binding.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Top
Remarks
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 access. Similarly, a client can use the BasicHttpBinding to communicate with services that expose endpoints that conform to WS-I BP 1.1, such as ASMX Web services or Windows Communication Foundation (WCF) services configured with the BasicHttpBinding.
Security is turned off by default, but can be added by setting the BasicHttpSecurityMode to a value other than None in the BasicHttpBinding(BasicHttpSecurityMode) constructor. It uses a "Text" message encoding and UTF-8 text encoding by default.
Examples
Dim binding As New BasicHttpBinding()
Dim transportSecurityBinding As New BasicHttpBinding(BasicHttpSecurityMode.Transport)
Dim envelopeVersion As EnvelopeVersion = binding.EnvelopeVersion
'Output of TxtEV to TextBlock: Soap11 (https://schemas.xmlsoap.org/soap/evelope/)
Dim TxtEV As String = envelopeVersion.ToString()
' Get default MaxBufferSize
Dim maxBufferSize As Integer = binding.MaxBufferSize
'Output of txtMBS to TextBlock: 65536
Dim txtMBS As String = maxBufferSize.ToString()
' Set new MaxBufferSize
binding.MaxReceivedMessageSize = 4096
Dim txtNewMBS As String = binding.MaxReceivedMessageSize.ToString()
' Get default MaxReceivedMessageSize
Dim maxReceivedBufferSize As Long = binding.MaxReceivedMessageSize
'Output of txtMBS: 65536
Dim txtMRBS As String = maxReceivedBufferSize.ToString()
' Set new MaxReceivedMessageSize
binding.MaxReceivedMessageSize = 4096
Dim txtNewMRBS As String = binding.MaxReceivedMessageSize.ToString()
' Get Scheme value
' Output of txtScheme: http
Dim txtScheme As String = binding.Scheme
Dim bDefaultHttpBinding As New BasicHttpBinding()
'Output txtSecurityMode: None
Dim txtDefaultSecurityMode As String = bDefaultHttpBinding.Security.Mode.ToString()
Dim bTHttpBinding As New BasicHttpBinding(BasicHttpSecurityMode.Transport)
'Output txtSecurityMode: Transport
Dim txtTSecurityMode As String = bTHttpBinding.Security.Mode.ToString()
Dim bTOHttpBinding As New BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly)
'Output txtSecurityMode: TransportCredentialOnly
Dim txtTOSecurityMode As String = bTOHttpBinding.Security.Mode.ToString()
'Gets the character encoding for the binding
Dim encoding As Encoding = binding.TextEncoding
'Output txtEncoding: System.Text.UTF8Encoding
Dim txtEncoding As String = encoding.ToString()
Dim unicodeEncoding As Encoding = New UnicodeEncoding()
'Set a Unicode encoding for the binding
binding.TextEncoding = unicodeEncoding
'Output txtEncoding: System.Text.UnicodeEncoding
Dim txtUEncoding As String = binding.TextEncoding.ToString()
Dim basicEHBinding As New BasicHttpBinding()
Dim bindingEC As BindingElementCollection = basicEHBinding.CreateBindingElements()
'Check on binding elements contained in the collection
Dim boolHTBE As Boolean = bindingEC.Contains(GetType(HttpTransportBindingElement))
'Returns true
Dim txtboolHTBE As String = boolHTBE.ToString()
Dim boolHSTBE As Boolean = bindingEC.Contains(GetType(HttpsTransportBindingElement))
'Returns false
Dim txtboolHSTBE As String = boolHSTBE.ToString()
BasicHttpBinding binding = new BasicHttpBinding();
BasicHttpBinding transportSecurityBinding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
EnvelopeVersion envelopeVersion = binding.EnvelopeVersion;
//Output of TxtEV to TextBlock: Soap11 (https://schemas.xmlsoap.org/soap/evelope/)
string TxtEV = envelopeVersion.ToString();
// Get default MaxBufferSize
int maxBufferSize = binding.MaxBufferSize;
//Output of txtMBS to TextBlock: 65536
string txtMBS = maxBufferSize.ToString();
// Set new MaxBufferSize
binding.MaxReceivedMessageSize = 4096;
string txtNewMBS = binding.MaxReceivedMessageSize.ToString();
// Get default MaxReceivedMessageSize
long maxReceivedBufferSize = binding.MaxReceivedMessageSize;
//Output of txtMBS: 65536
string txtMRBS = maxReceivedBufferSize.ToString();
// Set new MaxReceivedMessageSize
binding.MaxReceivedMessageSize = 4096;
string txtNewMRBS = binding.MaxReceivedMessageSize.ToString();
// Get Scheme value
// Output of txtScheme: http
string txtScheme = binding.Scheme;
BasicHttpBinding bDefaultHttpBinding = new BasicHttpBinding();
//Output txtSecurityMode: None
string txtDefaultSecurityMode = bDefaultHttpBinding.Security.Mode.ToString();
BasicHttpBinding bTHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
//Output txtSecurityMode: Transport
string txtTSecurityMode = bTHttpBinding.Security.Mode.ToString();
BasicHttpBinding bTOHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
//Output txtSecurityMode: TransportCredentialOnly
string txtTOSecurityMode = bTOHttpBinding.Security.Mode.ToString();
//Gets the character encoding for the binding
Encoding encoding = binding.TextEncoding;
//Output txtEncoding: System.Text.UTF8Encoding
string txtEncoding = encoding.ToString();
Encoding unicodeEncoding = new UnicodeEncoding();
//Set a Unicode encoding for the binding
binding.TextEncoding = unicodeEncoding;
//Output txtEncoding: System.Text.UnicodeEncoding
string txtUEncoding = binding.TextEncoding.ToString();
BasicHttpBinding basicEHBinding = new BasicHttpBinding();
BindingElementCollection bindingEC = basicEHBinding.CreateBindingElements();
//Check on binding elements contained in the collection
bool boolHTBE = bindingEC.Contains(typeof(HttpTransportBindingElement));
//Returns true
string txtboolHTBE = boolHTBE.ToString();
bool boolHSTBE = bindingEC.Contains(typeof(HttpsTransportBindingElement));
//Returns false
string txtboolHSTBE = boolHSTBE.ToString();
Version Information
Silverlight
Supported in: 5, 4, 3
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
XNA Framework
Supported in: Windows Phone OS 7.0
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.