SALES: 1-800-867-1380

BasicHttpRelayBinding Class

 

Represents a binding that a 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.

Namespace:   Microsoft.ServiceBus
Assembly:  Microsoft.ServiceBus (in Microsoft.ServiceBus.dll)

System.Object
  System.ServiceModel.Channels.Binding
    Microsoft.ServiceBus.BasicHttpRelayBinding

public class BasicHttpRelayBinding : Binding, IBindingRuntimePreferences

NameDescription
System_CAPS_pubmethodBasicHttpRelayBinding()

Initializes a new instance of the BasicHttpRelayBinding class.

System_CAPS_pubmethodBasicHttpRelayBinding(EndToEndBasicHttpSecurityMode, RelayClientAuthenticationType)

Initializes a new instance of the BasicHttpRelayBinding class with a specified type of security used by the binding and the authentication type used by the client.

System_CAPS_pubmethodBasicHttpRelayBinding(String)

Initializes a new instance of the BasicHttpRelayBinding class using the specified configuration.

NameDescription
System_CAPS_pubpropertyAllowCookies

Gets or sets a value that determines if the client allows cookies.

System_CAPS_pubpropertyCloseTimeout

(Inherited from Binding.)

System_CAPS_pubpropertyEnvelopeVersion

Gets the version of SOAP that is used for messages that are processed by this binding.

System_CAPS_pubpropertyHostNameComparisonMode

Gets or sets how the host name should be compared.

System_CAPS_pubpropertyIsDynamic

Gets or sets whether the binding element is dynamic.

System_CAPS_pubpropertyMaxBufferPoolSize

Gets or sets the maximum size allowed for a buffer pool that stores TCP messages processed by the binding.

System_CAPS_pubpropertyMaxBufferSize

Gets or sets the maximum size for a buffer that receives messages from the channel.

System_CAPS_pubpropertyMaxReceivedMessageSize

Gets or sets the maximum size for a message that can be received on a channel configured with this binding.

System_CAPS_pubpropertyMessageEncoding

Gets or sets the type of message encoding.

System_CAPS_pubpropertyMessageVersion

(Inherited from Binding.)

System_CAPS_pubpropertyName

(Inherited from Binding.)

System_CAPS_pubpropertyNamespace

(Inherited from Binding.)

System_CAPS_pubpropertyOpenTimeout

(Inherited from Binding.)

System_CAPS_pubpropertyProxyAddress

Gets or sets the proxy address.

System_CAPS_pubpropertyReaderQuotas

Gets or sets the reader quotas.

System_CAPS_pubpropertyReceiveTimeout

(Inherited from Binding.)

System_CAPS_pubpropertyScheme

Gets the URI transport scheme for the channels and listeners that are configured with this binding.(Overrides Binding.Scheme.)

System_CAPS_pubpropertySecurity

Gets the collection of security bindings used with this binding.

System_CAPS_pubpropertySendTimeout

(Inherited from Binding.)

System_CAPS_pubpropertyTextEncoding

Gets or sets the character encoding that is used for the message text.

System_CAPS_pubpropertyTransferMode

Gets or sets the transfer mode.

System_CAPS_pubpropertyUseDefaultWebProxy

Gets or sets a value that determines if the client uses the default web proxy.

NameDescription
System_CAPS_pubmethodBuildChannelFactory<TChannel>(BindingParameterCollection)

(Inherited from Binding.)

System_CAPS_pubmethodBuildChannelFactory<TChannel>(Object[])

(Inherited from Binding.)

System_CAPS_pubmethodBuildChannelListener<TChannel>(BindingParameterCollection)

(Inherited from Binding.)

System_CAPS_pubmethodBuildChannelListener<TChannel>(Object[])

(Inherited from Binding.)

System_CAPS_pubmethodBuildChannelListener<TChannel>(Uri, BindingParameterCollection)

(Inherited from Binding.)

System_CAPS_pubmethodBuildChannelListener<TChannel>(Uri, Object[])

(Inherited from Binding.)

System_CAPS_pubmethodBuildChannelListener<TChannel>(Uri, String, BindingParameterCollection)

(Inherited from Binding.)

System_CAPS_pubmethodBuildChannelListener<TChannel>(Uri, String, ListenUriMode, BindingParameterCollection)

(Inherited from Binding.)

System_CAPS_pubmethodBuildChannelListener<TChannel>(Uri, String, ListenUriMode, Object[])

(Inherited from Binding.)

System_CAPS_pubmethodBuildChannelListener<TChannel>(Uri, String, Object[])

(Inherited from Binding.)

System_CAPS_pubmethodCanBuildChannelFactory<TChannel>(BindingParameterCollection)

(Inherited from Binding.)

System_CAPS_pubmethodCanBuildChannelFactory<TChannel>(Object[])

(Inherited from Binding.)

System_CAPS_pubmethodCanBuildChannelListener<TChannel>(BindingParameterCollection)

(Inherited from Binding.)

System_CAPS_pubmethodCanBuildChannelListener<TChannel>(Object[])

(Inherited from Binding.)

System_CAPS_pubmethodCreateBindingElements()

Returns an ordered collection of binding elements contained in the current binding.(Overrides Binding.CreateBindingElements().)

System_CAPS_pubmethodEquals(Object)

(Inherited from Object.)

System_CAPS_protmethodFinalize()

(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodGetProperty<T>(BindingParameterCollection)

(Inherited from Binding.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethodToString()

(Inherited from Object.)

Windows Azure Service Bus supports only Full Trust code access security.

The BasicHttpRelayBinding is closely aligned with the standard BasicHttpBinding in the .NET Framework. The key difference between the standard BasicHttpBinding and the BasicHttpRelayBinding is that the latter creates publicly reachable and, if desired, publicly discoverable HTTP listener endpoint listening on the cloud-based Windows Azure Service Bus, while the standard binding listens through the standard HTTP.sys listener on the local Windows computer.

With its default settings, the BasicHttpRelayBinding supports SOAP 1.1 messaging conforming to the WS-I Basic profile 1.1.

Services using the BasicHttpRelayBinding register their endpoints on the Windows Azure Service Bus using the "http" or "https" URI scheme. Client channels created using the BasicHttpRelayBinding use HTTP/HTTPS on the default TCP ports 80 and 443 as the transport mechanism to talk to the respective endpoint in the Windows Azure Service Bus cloud. The data channel is SSL-protected if the endpoint URI scheme is "https" and the Security.Mode property is set to one of the EndToEndBasicHttpSecurityMode values: Transport or TransportWithMessageCredential.

The following example shows how to define and use BasicHttpRelayBinding with the default configuration for a service and client in an application configuration file.

<system.serviceModel>

  <bindings>
    <!-- Application Binding -->
    <basicHttpRelayBinding>
      <binding name="default" />
    </basicHttpRelayBinding>
  </bindings>

  <client>
    <!-- Application Endpoint -->
    <endpoint name="RelayEndpoint"
              contract="Microsoft.ServiceBus.Samples.IMyContract"
              binding="basicHttpRelayBinding"
              bindingConfiguration="default"
              behaviorConfiguration="ReplaceWithEndpointBehaviorName"
              address="ReplaceWithEndpointAddress" />
  </client>

  <services>
    <service name="Microsoft.ServiceBus.Samples.MyService">
      <!-- Keep address empty to use host base address, or -->
      <!-- replace with endpoint address. -->
      <endpoint name="RelayEndpoint"
                contract="Microsoft.ServiceBus.Samples.IMyContract"                   
                binding="basicHttpRelayBinding" 
                bindingConfiguration="default"
                behaviorConfiguration="ReplaceWithEndpointBehaviorName"
                address="" />
    </service>
  </services>

  <behaviors>
    <endpointBehaviors>
      <!-- Add endpoint behavior here. -->
    </endpointBehaviors>
  </behaviors>

</system.serviceModel>

The following example is similar to the previous example except that it defines a custom configuration for BasicHttpRelayBinding. It turns off the security mode and client authentication, which means that SOAP messages are sent unsecured and that the client is not required to present a security token to the Windows Azure Service Bus.

<system.serviceModel>

  <bindings>
    <!-- Application Binding -->
    <basicHttpRelayBinding>
      <binding name="customBinding">
        <!-- Turn off SSL and client authentication -->
        <security mode="None" relayClientAuthenticationType="None" />
      </binding>
    </basicHttpRelayBinding>
  </bindings>

  <client>
    <!-- Application Endpoint -->
    <!-- No behavior configuration is added to this endpoint as the client does not need to authenticate. -->
    <endpoint name="RelayEndpoint"
              contract="Microsoft.ServiceBus.Samples.IMyContract"
              binding="basicHttpRelayBinding"
              bindingConfiguration="customBinding"
              address="ReplaceWithEndpointAddress" />
  </client>

  <services>
    <service name="Microsoft.ServiceBus.Samples.MyService">
      <!-- Keep address empty to use host base address, or -->
      <!-- replace with endpoint address. -->
      <endpoint name="RelayEndpoint"
                contract="Microsoft.ServiceBus.Samples.IMyContract"                   
                binding="basicHttpRelayBinding" 
                bindingConfiguration="customBinding"
                behaviorConfiguration="ReplaceWithEndpointBehaviorName"
                address="" />
    </service>
  </services>

  <behaviors>
    <endpointBehaviors>
      <!-- Add endpoint behavior here. -->
    </endpointBehaviors>
  </behaviors>

</system.serviceModel>

The following example illustrates the use of BasicHttpRelayBinding programmatically with its default settings. The default settings of BasicHttpRelayBinding for the end-to-end security mode and client authentication type are EndToEndSecurityMode.Transport and RelayClientAuthenticationType.RelayAccessToken respectively.

This example starts by specifying the credentials the service and the client are expected to send to the Windows Azure Service Bus by creating an endpoint behavior. Next, it creates the binding, the service address, and starts the service host. After starting the service, a channel factory is created for the IMyChannel channel type that is used to generate a client channel to the service. Finally, the client channel is opened.

// Configure the credentials through an endpoint behavior.
TransportClientEndpointBehavior relayCredentials = new TransportClientEndpointBehavior();


relayCredentials.TokenProvider = 
  TokenProvider.CreateSharedAccessSignatureTokenProvider(keyName, key);



// Create the binding with default settings.
BasicHttpRelayBinding binding = new BasicHttpRelayBinding();

// Get the service address.
// Use the https scheme because by default the binding uses SSL for transport security.
Uri address = ServiceBusEnvironment.CreateServiceUri("https", serviceNamespace, "MyService");

// Create the service host.
ServiceHost host = new ServiceHost(typeof(MyService), address);
// Add the service endpoint with the BasicHttpRelayBinding.
host.AddServiceEndpoint(typeof(IMyContract), binding, address);
// Add the credentials through the endpoint behavior.
host.Description.Endpoints[0].Behaviors.Add(relayCredentials);
// Start the service.
host.Open();

// Create a channel factory for the specified channel type.
// This channel factory is used to create client channels to the service. 
// Each client channel the channel factory creates is configured to use the 
// BasicHttpRelayBinding that is passed to the constructor of the channel.
factory.ChannelFactory<IMyChannel> channelFactory = new ChannelFactory<IMyChannel>(
    binding, new EndpointAddress(address));
channelFactory.Endpoint.Behaviors.Add(relayCredentials);

// Create and open the client channel.
IMyChannel channel = channelFactory.CreateChannel();
channel.Open();

The following example is similar to the previous example except that it uses BasicHttpRelayBinding with custom settings. It turns off the SSL security mode and client authentication, which means that SOAP messages are sent unsecured and that the client is not required to present a security token to the Windows Azure Service Bus. Because SSL is turned off, the http scheme is used in the service address. Also, since the client is not required to authenticate, no endpoint behavior for the credentials is added to the client channel. Note that the behavior is still added to the service endpoint because the service application always authenticates with the Windows Azure Service Bus.

// Configure the credentials through an endpoint behavior.
TransportClientEndpointBehavior relayCredentials = new TransportClientEndpointBehavior();
relayCredentials.TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider(keyName, key);




// Create the binding with custom settings.
BasicHttpRelayBinding binding = new BasicHttpRelayBinding();
// SOAP messages are not SSL-protected.
binding.Security.Mode = EndToEndSecurityMode.None;
// The client is not required to present a security token to the
// AppFabric Service Bus.
binding.Security.RelayClientAuthenticationType = RelayClientAuthenticationType.None;

// Get the service address.
// Use the http scheme because SSL security is turned off in our binding.
Uri address = ServiceBusEnvironment.CreateServiceUri("http", serviceNamespace, "MyService");

// Create the service host.
ServiceHost host = new ServiceHost(typeof(MyService), address);
// Add the service endpoint with the BasicHttpRelayBinding.
host.AddServiceEndpoint(typeof(IMyContract), binding, address);
// Add the credentials through the endpoint behavior.
host.Description.Endpoints[0].Behaviors.Add(relayCredentials);
// Start the service.
host.Open();

// Create a channel factory for the specified channel type.
// We do not add the endpoint behavior with the credentials to the channel 
// factory because client authentication is turned off in the binding used.
// This channel factory is used to create client channels to the service. 
// Each client channel the channel factory creates is configured to use the 
// BasicHttpRelayBinding that is passed to the constructor of the channel.
factory.ChannelFactory<IMyChannel> channelFactory = new ChannelFactory<IMyChannel>(
    binding, new EndpointAddress(address));

// Create and open the client channel.
IMyChannel channel = channelFactory.CreateChannel();
channel.Open();

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

Return to top
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft