Export (0) Print
Expand All

BasicHttpBinding Class

Represents a binding that a 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
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

public class BasicHttpBinding : Binding, 
	IBindingRuntimePreferences

The BasicHttpBinding type exposes the following members.

  NameDescription
Public methodSupported by Portable Class LibraryBasicHttpBinding()Initializes a new instance of the BasicHttpBinding class.
Public methodSupported by Portable Class LibraryBasicHttpBinding(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.
Public propertyBypassProxyOnLocalGets or sets a value that indicates whether to bypass the proxy server for local addresses.
Public propertySupported by Portable Class LibraryCloseTimeoutGets or sets the interval of time provided for a connection to close before the transport raises an exception. (Inherited from Binding.)
Public propertySupported by Portable Class LibraryEnvelopeVersionGets the version of SOAP that is used for messages that are processed by this binding.
Public propertyHostNameComparisonModeGets or sets a value that indicates whether the hostname is used to reach the service when matching the URI.
Public propertyMaxBufferPoolSizeGets or sets the maximum amount of memory that is allocated for use by the manager of the message buffers that receive messages from the channel.
Public propertySupported by Portable Class LibraryMaxBufferSizeGets or sets the maximum size for a buffer that receives messages from the channel.
Public propertySupported by Portable Class LibraryMaxReceivedMessageSizeGets or sets the maximum size for a message that can be received on a channel configured with this binding.
Public propertyMessageEncodingGets or sets whether MTOM or Text is used to encode SOAP messages.
Public propertySupported by Portable Class LibraryMessageVersionGets the message version used by clients and services configured with the binding. (Inherited from Binding.)
Public propertySupported by Portable Class LibraryNameGets or sets the name of the binding. (Inherited from Binding.)
Public propertySupported by Portable Class LibraryNamespaceGets or sets the XML namespace of the binding. (Inherited from Binding.)
Public propertySupported by Portable Class LibraryOpenTimeoutGets 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.
Public propertyReaderQuotasGets or sets constraints on the complexity of SOAP messages that can be processed by endpoints configured with this binding.
Public propertySupported by Portable Class LibraryReceiveTimeoutGets 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. (Overrides Binding.Scheme.)
Public propertySupported by Portable Class LibrarySecurityGets the type of security used with this binding.
Public propertySupported by Portable Class LibrarySendTimeoutGets 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.
Public propertyTransferModeGets or sets a value that indicates whether messages are sent buffered or streamed.
Public propertyUseDefaultWebProxyGets or sets a value that indicates whether the auto-configured HTTP proxy of the system should be used, if available.
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. (Inherited from Binding.)
Public methodSupported by Portable Class LibraryBuildChannelFactory<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 LibraryCanBuildChannelFactory<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 LibraryCanBuildChannelFactory<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 LibraryCreateBindingElementsReturns an ordered collection of binding elements contained in the current binding. (Overrides Binding.CreateBindingElements().)
Public methodSupported by Portable Class LibraryEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Portable Class LibraryFinalizeAllows 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 LibraryGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Portable Class LibraryGetProperty<T>Returns a typed object requested, if present, from the appropriate layer in the binding stack. (Inherited from Binding.)
Public methodSupported by Portable Class LibraryGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Portable Class LibraryMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
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.
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.
Public methodSupported by Portable Class LibraryToStringReturns 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.
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 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, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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.

Community Additions

ADD
Show:
© 2014 Microsoft