Export (0) Print
Expand All

BasicHttpBinding Class

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.

Namespace:  System.ServiceModel
Assemblies:   System.ServiceModel (in System.ServiceModel.dll)
  System.ServiceModel.Http (in System.ServiceModel.Http.dll)

public class BasicHttpBinding : HttpBindingBase

The BasicHttpBinding type exposes the following members.

  NameDescription
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsBasicHttpBinding()Initializes a new instance of the BasicHttpBinding class.
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsBasicHttpBinding(BasicHttpSecurityMode)Initializes a new instance of the BasicHttpBinding class with a specified type of security used by the binding.
Public methodBasicHttpBinding(String)Initializes a new instance of the BasicHttpBinding class with a binding specified by its configuration name.
Top

  NameDescription
Public propertyAllowCookiesGets or sets a value that indicates whether the client accepts cookies and propagates them on future requests. (Inherited from HttpBindingBase.)

In .NET Framework Client Profile 4, this member is AllowCookies.
Public propertyBypassProxyOnLocalGets or sets a value that indicates whether to bypass the proxy server for local addresses. (Inherited from HttpBindingBase.)

In .NET Framework Client Profile 4, this member is BypassProxyOnLocal.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsCloseTimeoutGets or sets the interval of time provided for a connection to close before the transport raises an exception. (Inherited from Binding.)
Public propertyEnableHttpCookieContainer Obsolete. Gets or sets a value that indicates whether HTTP cookie container is enabled.
Public propertySupported by Portable Class LibraryEnvelopeVersionGets the version of SOAP that is used for messages that are processed by this binding. (Inherited from HttpBindingBase.)

In .NET Framework Client Profile 4, this member is EnvelopeVersion.


In Portable Class Library Portable Class Library, this member is EnvelopeVersion.


In  Windows Phone 8.1, this member is EnvelopeVersion.


In  Windows Phone Silverlight 8.1, this member is EnvelopeVersion.


In  Windows Phone Silverlight 8, this member is EnvelopeVersion.
Public propertyHostNameComparisonModeGets or sets a value that indicates whether the hostname is used to reach the service when matching the URI. (Inherited from HttpBindingBase.)

In .NET Framework Client Profile 4, this member is HostNameComparisonMode.
Public propertyMaxBufferPoolSizeGets or sets the maximum amount of memory, in bytes, that is allocated for use by the manager of the message buffers that receive messages from the channel. (Inherited from HttpBindingBase.)

In .NET Framework Client Profile 4, this member is MaxBufferPoolSize.
Public propertySupported by Portable Class LibraryMaxBufferSizeGets or sets the maximum size, in bytes, for a buffer that receives messages from the channel. (Inherited from HttpBindingBase.)

In .NET Framework Client Profile 4, this member is MaxBufferSize.


In Portable Class Library Portable Class Library, this member is MaxBufferSize.


In  Windows Phone 8.1, this member is MaxBufferSize.


In  Windows Phone Silverlight 8.1, this member is MaxBufferSize.


In  Windows Phone Silverlight 8, this member is MaxBufferSize.
Public propertySupported by Portable Class LibraryMaxReceivedMessageSizeGets or sets the maximum size, in bytes, for a message that can be received on a channel configured with this binding. (Inherited from HttpBindingBase.)

In .NET Framework Client Profile 4, this member is MaxReceivedMessageSize.


In Portable Class Library Portable Class Library, this member is MaxReceivedMessageSize.


In  Windows Phone 8.1, this member is MaxReceivedMessageSize.


In  Windows Phone Silverlight 8.1, this member is MaxReceivedMessageSize.


In  Windows Phone Silverlight 8, this member is MaxReceivedMessageSize.
Public propertyMessageEncodingGets or sets whether MTOM or Text is used to encode SOAP messages.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsMessageVersionGets the message version used by clients and services configured with the binding. (Inherited from Binding.)
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsNameGets or sets the name of the binding. (Inherited from Binding.)
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsNamespaceGets or sets the XML namespace of the binding. (Inherited from Binding.)
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsOpenTimeoutGets or sets the interval of time provided for a connection to open before the transport raises an exception. (Inherited from Binding.)
Public propertyProxyAddressGets or sets the URI address of the HTTP proxy. (Inherited from HttpBindingBase.)

In .NET Framework Client Profile 4, this member is ProxyAddress.
Public propertyReaderQuotasGets or sets the constraints on the complexity of SOAP messages that can be processed by endpoints configured with this binding. (Inherited from HttpBindingBase.)

In .NET Framework Client Profile 4, this member is ReaderQuotas.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsReceiveTimeoutGets 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.)
Public propertySupported by Portable Class LibrarySchemeGets the URI transport scheme for the channels and listeners that are configured with this binding. (Inherited from HttpBindingBase.)

In .NET Framework Client Profile, this member is overridden by Scheme.


In Portable Class Library, this member is overridden by Scheme.


In , this member is overridden by Scheme.


In , this member is overridden by Scheme.


In , this member is overridden by Scheme.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsSecurityGets the type of security used with this binding.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsSendTimeoutGets or sets the interval of time provided for a write operation to complete before the transport raises an exception. (Inherited from Binding.)
Public propertySupported by Portable Class LibraryTextEncodingGets or sets the character encoding that is used for the message text. (Inherited from HttpBindingBase.)

In .NET Framework Client Profile 4, this member is TextEncoding.


In Portable Class Library Portable Class Library, this member is TextEncoding.


In  Windows Phone 8.1, this member is TextEncoding.


In  Windows Phone Silverlight 8.1, this member is TextEncoding.


In  Windows Phone Silverlight 8, this member is TextEncoding.
Public propertyTransferModeGets or sets a value that indicates whether messages are sent buffered or streamed. (Inherited from HttpBindingBase.)

In .NET Framework Client Profile 4, this member is TransferMode.
Public propertyUseDefaultWebProxyGets or sets a value that indicates whether the auto-configured HTTP proxy of the system should be used, if available. (Inherited from HttpBindingBase.)

In .NET Framework Client Profile 4, this member is UseDefaultWebProxy.
Top

  NameDescription
Public methodSupported by Portable Class LibraryBuildChannelFactory<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. (Overrides Binding.BuildChannelFactory<TChannel>(BindingParameterCollection).)

In .NET Framework Client Profile 4, this member is inherited from Binding.BuildChannelFactory<TChannel>(BindingParameterCollection).


In Portable Class Library Portable Class Library, this member is inherited from Binding.BuildChannelFactory<TChannel>(BindingParameterCollection).


In  Windows Phone 8.1, this member is inherited from Binding.BuildChannelFactory<TChannel>(BindingParameterCollection).


In  Windows Phone Silverlight 8.1, this member is inherited from Binding.BuildChannelFactory<TChannel>(BindingParameterCollection).


In  Windows Phone Silverlight 8, this member is inherited from Binding.BuildChannelFactory<TChannel>(BindingParameterCollection).
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsBuildChannelFactory<TChannel>(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.)
Public methodBuildChannelListener<TChannel>(BindingParameterCollection)Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified by a collection of binding parameters. (Inherited from Binding.)
Public methodBuildChannelListener<TChannel>(Object[])Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified. (Inherited from Binding.)
Public methodBuildChannelListener<TChannel>(Uri, Object[])Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified. (Inherited from Binding.)
Public methodBuildChannelListener<TChannel>(Uri, BindingParameterCollection)Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified. (Inherited from Binding.)
Public methodBuildChannelListener<TChannel>(Uri, String, Object[])Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified. (Inherited from Binding.)
Public methodBuildChannelListener<TChannel>(Uri, String, BindingParameterCollection)Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified. (Inherited from Binding.)
Public methodBuildChannelListener<TChannel>(Uri, String, ListenUriMode, Object[])Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified. (Inherited from Binding.)
Public methodBuildChannelListener<TChannel>(Uri, String, ListenUriMode, BindingParameterCollection)Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified. (Inherited from Binding.)
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsCanBuildChannelFactory<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.)
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsCanBuildChannelFactory<TChannel>(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.)
Public methodCanBuildChannelListener<TChannel>(BindingParameterCollection)Returns a value that indicates whether the current binding can build a channel listener stack on the service that satisfies the collection of binding parameters specified. (Inherited from Binding.)
Public methodCanBuildChannelListener<TChannel>(Object[])Returns a value that indicates whether the current binding can build a channel listener stack on the service that satisfies the criteria specified in an array of objects. (Inherited from Binding.)
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsCreateBindingElementsCreates and returns an ordered collection of binding elements contained in the current binding. (Overrides Binding.CreateBindingElements().)
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetProperty<T>Returns a typed object requested, if present, from the appropriate layer in the binding stack. (Inherited from Binding.)
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodShouldSerializeEnableHttpCookieContainerIndicates whether the http cookie container should enable the serialization.
Public methodShouldSerializeNameReturns whether the name of the binding should be serialized. (Inherited from Binding.)
Public methodShouldSerializeNamespaceReturns whether the namespace of the binding should be serialized. (Inherited from Binding.)
Public methodShouldSerializeReaderQuotasReturns whether the constraint values placed on the complexity of SOAP message structure should be serialized. (Inherited from HttpBindingBase.)

In .NET Framework Client Profile 4, this member is ShouldSerializeReaderQuotas().
Public methodShouldSerializeSecurityReturns whether security settings should be serialized based upon whether serialization already occurs, for example at the message or transport level.
Public methodShouldSerializeTextEncodingReturns whether settings for text encoding should be serialized. (Inherited from HttpBindingBase.)

In .NET Framework Client Profile 4, this member is ShouldSerializeTextEncoding().
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Explicit interface implemetationPrivate propertyIBindingRuntimePreferences.ReceiveSynchronouslyGets a value that indicates whether incoming requests are handled synchronously or asynchronously. (Inherited from HttpBindingBase.)
Explicit interface implemetationPrivate propertyIBindingRuntimePreferences.ReceiveSynchronouslyGets a value that indicates whether incoming requests are handled synchronously or asynchronously.
Top

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 exposing 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 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.

The following example shows how to configure the BasicHttpBinding in an application configuration file.

<system.serviceModel>
  <services>
    <service
        name="Microsoft.ServiceModel.Samples.CalculatorService"
        behaviorConfiguration="CalculatorServiceBehavior">
      <!-- use base address provided by host -->
      <!-- specify BasicHttp binding and a binding configuration to use -->
      <endpoint address=""
                binding="basicHttpBinding"
                bindingConfiguration="Binding1"
                contract="Microsoft.ServiceModel.Samples.ICalculator" />
    </service>
  </services>

  <bindings>
    <!-- 
          Following is the expanded configuration section for a BasicHttpBinding.
          Each property is configured with the default value.
          See the TransportSecurity, and MessageSecurity samples in the
          Basic directory to learn how to configure these features.
          -->
    <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>

  <!--For debugging purposes set the returnUnknownExceptionsAsFaults attribute to true-->
  <behaviors>
    <serviceBehaviors>
      <behavior name="CalculatorServiceBehavior">
        <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>

</system.serviceModel>

The following example shows how to programmatically configure BasicHttpBinding.

    [ServiceContract(Namespace = "http://UE.ServiceModel.Samples")]
    public interface ICalculator
    {
        [OperationContract(IsOneWay = false)]
        double Add(double n1, double n2);
        [OperationContract(IsOneWay = false)]
        double Subtract(double n1, double n2);
        [OperationContract(IsOneWay = false)]
        double Multiply(double n1, double n2);
        [OperationContract(IsOneWay = false)]
        double Divide(double n1, double n2);
    }

    public class CalculatorService : ICalculator
    {
        public double Add(double n1, double n2)
        {
            double result = n1 + n2;
            Console.WriteLine("Received Add({0},{1})", n1, n2);
            Console.WriteLine("Return: {0}", result);
            return result;
        }

        public double Subtract(double n1, double n2)
        {
            double result = n1 - n2;
            Console.WriteLine("Received Subtract({0},{1})", n1, n2);
            Console.WriteLine("Return: {0}", result);
            return result;
        }

        public double Multiply(double n1, double n2)
        {
            double result = n1 * n2;
            Console.WriteLine("Received Multiply({0},{1})", n1, n2);
            Console.WriteLine("Return: {0}", result);
            return result;
        }

        public double Divide(double n1, double n2)
        {
            double result = n1 / n2;
            Console.WriteLine("Received Divide({0},{1})", n1, n2);
            Console.WriteLine("Return: {0}", result);
            return result;
        }

        public static void Main()
        {
            BasicHttpBinding binding = new BasicHttpBinding();
            binding.Name = "binding1";
            binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
            binding.Security.Mode = BasicHttpSecurityMode.None;

            Uri baseAddress = new Uri("http://localhost:8000/servicemodelsamples/service");
            Uri address = new Uri("http://localhost:8000/servicemodelsamples/service/calc");

            // Create a ServiceHost for the CalculatorService type and provide the base address.
            ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress);

            serviceHost.AddServiceEndpoint(typeof(ICalculator), binding, address);

            // Open the ServiceHostBase to create listeners and start listening for messages.
            serviceHost.Open();

            // The service can now be accessed.
            Console.WriteLine("The service is ready.");
            Console.WriteLine("Press <ENTER> to terminate service.");
            Console.WriteLine();
            Console.ReadLine();
	    
            // Close the ServiceHostBase to shutdown the service.
            serviceHost.Close();

        }
    }

.NET Framework

Supported in: 4.5.3, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft