HttpTransportBindingElement Class
Assembly: System.ServiceModel (in system.servicemodel.dll)
'Declaration Public Class HttpTransportBindingElement Inherits TransportBindingElement Implements IWsdlExportExtension, IPolicyExportExtension 'Usage Dim instance As HttpTransportBindingElement
public class HttpTransportBindingElement extends TransportBindingElement implements IWsdlExportExtension, IPolicyExportExtension
public class HttpTransportBindingElement extends TransportBindingElement implements IWsdlExportExtension, IPolicyExportExtension
Not applicable.
The HttpTransportBindingElement class is the starting point for creating a custom binding that implements the HTTP transport protocol. HTTP is the primary transport used for interoperability purposes. This transport is supported by the Windows Communication Foundation (WCF) to ensure interoperability with other non-WCF Web services stacks.
The WCF service model uses this class to create factory objects that implement the IChannelFactory and IChannelListener interfaces. These factory objects in turn create the channels and listeners that transmit SOAP messages using the HTTP protocol.
You configure the factories that this class creates by setting its properties, such as: AuthenticationScheme, HostNameComparisonMode, and MaxBufferSize.
You can also set properties on the base class, TransportBindingElement, such as: ManualAddressing, MaxReceivedMessageSize, and MaxBufferPoolSize. For a complete list of properties, see TransportBindingElement.
The following code illustrates how to imperatively use the HttpTransportBindingElement:
Uri baseAddress = new Uri("http://localhost:8000/servicemodelsamples/service"); // Create a ServiceHost for the CalculatorService type and provide the base address. using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress)) { // Create a custom binding that contains two binding elements. ReliableSessionBindingElement reliableSession = new ReliableSessionBindingElement(); reliableSession.Ordered = true; HttpTransportBindingElement httpTransport = new HttpTransportBindingElement(); httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous; httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; CustomBinding binding = new CustomBinding(reliableSession, httpTransport); // Add an endpoint using that binding. serviceHost.AddServiceEndpoint(typeof(ICalculator), binding, ""); // Add a MEX endpoint. ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); smb.HttpGetEnabled = true; smb.HttpGetUrl = new Uri("http://localhost:8001/servicemodelsamples"); serviceHost.Description.Behaviors.Add(smb); // 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(); }
HttpTransportBindingElement may also be used in a configuration file as demonstrated in the following configuration:
<bindings>
<customBinding>
<binding name="Binding1">
<reliableSession acknowledgementInterval="00:00:00.2000000" enableFlowControl="true"
maxTransferWindowSize="32" inactivityTimeout="00:10:00" maxPendingChannels="128"
maxRetryCount="8" ordered="true" />
<security mode="None"/>
<httpTransport authenticationScheme="Anonymous" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
proxyAuthenticationScheme="Anonymous" realm=""
useDefaultWebProxy="true" />
</binding>
</customBinding>
</bindings>
System.ServiceModel.Channels.BindingElement
System.ServiceModel.Channels.TransportBindingElement
System.ServiceModel.Channels.HttpTransportBindingElement
System.ServiceModel.Channels.HttpsTransportBindingElement
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.