Export (0) Print
Expand All

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.

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

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

public class BasicHttpRelayBinding : Binding, 
	IBindingRuntimePreferences

The BasicHttpRelayBinding type exposes the following members.

  NameDescription
Public methodBasicHttpRelayBinding()Initializes a new instance of the BasicHttpRelayBinding class.
Public methodBasicHttpRelayBinding(String)Initializes a new instance of the BasicHttpRelayBinding class using the specified configuration.
Public methodBasicHttpRelayBinding(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.
Top

  NameDescription
Public propertyAllowCookiesGets or sets a value that determines if the client allows cookies.
Public propertyCloseTimeout (Inherited from Binding.)
Public propertyEnvelopeVersionGets the version of SOAP that is used for messages that are processed by this binding.
Public propertyHostNameComparisonModeGets or sets how the host name should be compared.
Public propertyIsDynamicGets or sets whether the binding element is dynamic.
Public propertyMaxBufferPoolSizeGets or sets the maximum size allowed for a buffer pool that stores TCP messages processed by the binding.
Public propertyMaxBufferSizeGets or sets the maximum size for a buffer that receives messages from the channel.
Public propertyMaxReceivedMessageSizeGets or sets the maximum size for a message that can be received on a channel configured with this binding.
Public propertyMessageEncodingGets or sets the type of message encoding.
Public propertyMessageVersion (Inherited from Binding.)
Public propertyName (Inherited from Binding.)
Public propertyNamespace (Inherited from Binding.)
Public propertyOpenTimeout (Inherited from Binding.)
Public propertyProxyAddressGets or sets the proxy address.
Public propertyReaderQuotasGets or sets the reader quotas.
Public propertyReceiveTimeout (Inherited from Binding.)
Public propertySchemeGets the URI transport scheme for the channels and listeners that are configured with this binding. (Overrides Binding.Scheme.)
Public propertySecurityGets the collection of security bindings used with this binding.
Public propertySendTimeout (Inherited from Binding.)
Public propertyTextEncodingGets or sets the character encoding that is used for the message text.
Public propertyTransferModeGets or sets the transfer mode.
Public propertyUseDefaultWebProxyGets or sets a value that determines if the client uses the default web proxy.
Top

  NameDescription
Public methodBuildChannelFactory<TChannel>(Object[]) (Inherited from Binding.)
Public methodBuildChannelFactory<TChannel>(BindingParameterCollection) (Inherited from Binding.)
Public methodBuildChannelListener<TChannel>(Object[]) (Inherited from Binding.)
Public methodBuildChannelListener<TChannel>(BindingParameterCollection) (Inherited from Binding.)
Public methodBuildChannelListener<TChannel>(Uri, Object[]) (Inherited from Binding.)
Public methodBuildChannelListener<TChannel>(Uri, BindingParameterCollection) (Inherited from Binding.)
Public methodBuildChannelListener<TChannel>(Uri, String, Object[]) (Inherited from Binding.)
Public methodBuildChannelListener<TChannel>(Uri, String, BindingParameterCollection) (Inherited from Binding.)
Public methodBuildChannelListener<TChannel>(Uri, String, ListenUriMode, Object[]) (Inherited from Binding.)
Public methodBuildChannelListener<TChannel>(Uri, String, ListenUriMode, BindingParameterCollection) (Inherited from Binding.)
Public methodCanBuildChannelFactory<TChannel>(Object[]) (Inherited from Binding.)
Public methodCanBuildChannelFactory<TChannel>(BindingParameterCollection) (Inherited from Binding.)
Public methodCanBuildChannelListener<TChannel>(Object[]) (Inherited from Binding.)
Public methodCanBuildChannelListener<TChannel>(BindingParameterCollection) (Inherited from Binding.)
Public methodCreateBindingElementsReturns an ordered collection of binding elements contained in the current binding. (Overrides Binding.CreateBindingElements().)
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetProperty<T> (Inherited from Binding.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodShouldSerializeName (Inherited from Binding.)
Public methodShouldSerializeNamespace (Inherited from Binding.)
Public methodToString (Inherited from Object.)
Top

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

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.CredentialType = TransportClientCredentialType.SharedSecret;
relayCredentials.Credentials.SharedSecret.IssuerName = issuerName;
relayCredentials.Credentials.SharedSecret.IssuerSecret = issuerSecret;

// 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.CredentialType = TransportClientCredentialType.SharedSecret;
relayCredentials.Credentials.SharedSecret.IssuerName = issuerName;
relayCredentials.Credentials.SharedSecret.IssuerSecret = issuerSecret;

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

Community Additions

ADD
Show:
© 2014 Microsoft