SALES: 1-800-867-1380

NetOnewayRelayBinding Class

Represents a binding for a secure, one-way connection through the cloud.

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

public class NetOnewayRelayBinding : Binding, 
	IBindingRuntimePreferences

The NetOnewayRelayBinding type exposes the following members.

  NameDescription
Public methodNetOnewayRelayBinding()Initializes a new instance of the NetOnewayRelayBinding class.
Public methodNetOnewayRelayBinding(String)Initializes a new instance of the NetOnewayRelayBinding class using the specified configuration.
Protected methodNetOnewayRelayBinding(NetOnewayRelaySecurity)Initializes a new instance of the NetOnewayRelayBinding class, using the specified security settings.
Public methodNetOnewayRelayBinding(EndToEndSecurityMode, RelayClientAuthenticationType)Initializes a new instance of the NetOnewayRelayBinding class, using the specified security mode and authentication type.
Protected methodNetOnewayRelayBinding(RelayedOnewayConnectionMode, EndToEndSecurityMode, RelayClientAuthenticationType)Initializes a new instance of the NetOnewayRelayBinding class, using the specified connection and security modes, as well as the authentication type.
Protected methodNetOnewayRelayBinding(RelayedOnewayTransportBindingElement, BinaryMessageEncodingBindingElement, NetOnewayRelaySecurity)Initializes a new instance of the NetOnewayRelayBinding class, using the specified transport, encoding, and security.
Top

  NameDescription
Public propertyCloseTimeout (Inherited from Binding.)
Public propertyEnvelopeVersionGets the version of SOAP that is used for messages processed by this binding.
Public propertyListenBacklogGets or sets the maximum number of queued connection requests that can be pending.
Public propertyMaxBufferPoolSizeGets or sets the maximum size allowed for a buffer pool that stores messages processed by the binding.
Public propertyMaxBufferSizeGets or sets a value that specifies the maximum size, in bytes, of the buffer used to store messages in memory.
Public propertyMaxConnectionsGets or sets a value that controls the maximum number of connections to be pooled for subsequent reuse on the client and the maximum number of connections allowed to be pending dispatch on the server.
Public propertyMaxReceivedMessageSizeGets or sets the maximum size for a received message that is processed by the binding.
Protected propertyMessageSecurityVersionGets the message security version.
Public propertyMessageVersion (Inherited from Binding.)
Public propertyName (Inherited from Binding.)
Public propertyNamespace (Inherited from Binding.)
Public propertyOpenTimeout (Inherited from Binding.)
Public propertyReaderQuotasGets or sets constraints on the complexity of SOAP messages that can be processed by endpoints configured with this binding.
Public propertyReceiveTimeout (Inherited from Binding.)
Public propertySchemeGets the URI scheme for the transport. (Overrides Binding.Scheme.)
Public propertySecurityGets an object that specifies the type of security used with services configured with this binding.
Public propertySendTimeout (Inherited from Binding.)
Top

  NameDescription
Protected methodApplyConfigurationApplies the settings from the configuration element that corresponds to the specified name to the current instance of this binding element.
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 methodCreateBindingElementsCreates a set of binding elements. (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
Protected fieldencodingRepresents the encoding for the binding. Along with the security settings and transport type, the encoding represents the three core properties of a binding.
Protected fieldtransportSpecifies the transport type for the binding. Along with the encoding and security settings, the transport type represents the three core properties of a binding.
Top

  NameDescription
Explicit interface implemetationPrivate propertyIBindingRuntimePreferences.ReceiveSynchronouslyGets a value that indicates whether incoming requests can be handled more efficiently synchronously or asynchronously.
Top

NoteNote

By default, NetOnewayRelayBinding uses Transport Security.

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

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

<system.serviceModel>

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

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

  <services>
    <service name="Microsoft.ServiceBus.Samples.OnewayService">
      <!-- Keep address empty to use host base address, or -->
      <!-- replace with endpoint address. -->
      <endpoint name="RelayEndpoint"
                contract="Microsoft.ServiceBus.Samples.IOnewayContract"                   
                binding="netOnewayRelayBinding" 
                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 NetOneWayRelayBinding. 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 -->
    <netOnewayRelayBinding>
      <binding name="customBinding">
        <!-- Turn off SSL and client authentication -->
        <security mode="None" relayClientAuthenticationType="None" />
      </binding>
    </netOnewayRelayBinding>
  </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.IOnewayContract"
              binding="netOnewayRelayBinding"
              bindingConfiguration="customBinding"              
              address="ReplaceWithEndpointAddress" />
  </client>

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

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

</system.serviceModel>

The following example illustrates the use of NetOneWayRelayBinding programmatically with its default settings. The default settings of NetOneWayRelayBinding for the end-to-end security mode and client authentication type are EndToEndSecurityMode.Transport and RelayClientAuthenticationType.RelayAccessToken respectively. This example is a modified version of the NetOneWay SDK sample, which specifies the binding for the service endpoint and the client channel programmatically instead of specifying it in the application configuration file. The NetOneWay SDK sample can be found in the SDK install directory under \Samples\ServiceBus\ExploringFeatures\Bindings\NetOneWay.

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 IOneWayChannel 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.
NetOnewayRelayBinding binding = new NetOnewayRelayBinding();

// Get the service address.
Uri address = ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespace, "OnewayService");

// Create the service host.
ServiceHost host = new ServiceHost(typeof(OnewayService), address);
// Add the service endpoint with the OneWayRelayBinding.
host.AddServiceEndpoint(typeof(IOnewayContract), 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 IOnewayChannel 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 
// NetOneWayRelayBinding that is passed to the constructor of the channel factory.
ChannelFactory<IOnewayChannel> channelFactory = new ChannelFactory<IOnewayChannel>(
    binding, new EndpointAddress(address));
channelFactory.Endpoint.Behaviors.Add(relayCredentials);

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

The following example is similar to the previous example except that it uses NetOneWayRelayBinding with custom settings. 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. 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.
NetOnewayRelayBinding binding = new NetOnewayRelayBinding();
// 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.
Uri address = ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespace, "OnewayService");

// Create the service host.
ServiceHost host = new ServiceHost(typeof(OnewayService), address);
// Add the service endpoint with the OneWayRelayBinding.
host.AddServiceEndpoint(typeof(IOnewayContract), 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 IOnewayChannel 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 
// NetOneWayRelayBinding that is passed to the constructor of the channel factory.
ChannelFactory<IOnewayChannel> channelFactory = new ChannelFactory<IOnewayChannel>(
    binding, new EndpointAddress(address));

// Create and open the client channel.
IOnewayChannel 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.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft