A binding used to configure endpoints for Web services that are exposed through HTTP requests instead of SOAP messages.
Assembly: Microsoft.ServiceBus (in Microsoft.ServiceBus.dll)
Thetype exposes the following members.
|WebHttpRelayBinding()||Initializes a new instance of the class.|
|WebHttpRelayBinding(String)||Initializes a new instance of the class using the specified configuration name.|
|WebHttpRelayBinding(EndToEndWebHttpSecurityMode, RelayClientAuthenticationType)||Initializes a new instance of the class using the specified type of security and relay client authentication.|
|AllowCookies||Gets or sets a value that specifies whether cookies are allowed in the messages sent via the .|
|CloseTimeout||(Inherited from Binding.)|
|ContentTypeMapper||Gets or sets the content type mapper.|
|EnvelopeVersion||Gets the SOAP envelope version.|
|HostNameComparisonMode||Gets or sets the comparison mode used on the host name.|
|IsDynamic||Gets or sets whether the relay binding is dynamic.|
|MaxBufferPoolSize||Gets or sets the maximum buffer pool size used by the transport.|
|MaxBufferSize||Gets or sets the maximum buffer size supported by the transport.|
|MaxReceivedMessageSize||Gets or sets the maximum allowable message size that can be received.|
|MessageVersion||(Inherited from Binding.)|
|Name||(Inherited from Binding.)|
|Namespace||(Inherited from Binding.)|
|OpenTimeout||(Inherited from Binding.)|
|ProxyAddress||Gets or sets a URI that contains the address of the proxy to use for HTTP requests.|
|ReaderQuotas||Gets or sets xml reader quotas on the messages processed.|
|ReceiveTimeout||(Inherited from Binding.)|
|Scheme||Gets the scheme for the endpoints used with the binding. (Overrides Binding::Scheme.)|
|Security||Gets the security settings for the current instance.|
|SendTimeout||(Inherited from Binding.)|
|TransferMode||Gets or sets the transfer mode.|
|UseDefaultWebProxy||Gets or sets a value that indicates whether the machine-wide proxy settings are used rather than the user specific settings.|
|WriteEncoding||Gets or sets the character encoding that is used to write the message text.|
The is ideal for integrating simple non-WCF clients with Service Bus endpoints because it exposes REST endpoints for web services. Therefore, any client capable of REST-ful communication can interact with services (listeners) hosted in the Service Bus via the . However, if more sophisticated security and reliability features are required, then WS2007HttpRelayBinding would be more appropriate.
The following example shows how to define and use WebHttpRelayBinding in an application configuration file. The binding in this example has client authentication turned off, which means that the client is not required to present a security token to the Windows Azure Service Bus.
<system.serviceModel> <bindings> <!-- Application Binding --> <webHttpRelayBinding> <binding name="customBinding"> <!-- Turn off client authentication so that client does not need to present credential through browser or fiddler --> <security relayClientAuthenticationType="None" /> </binding> </webHttpRelayBinding> </bindings> <services> <!-- Application Service --> <service name="Microsoft.ServiceBus.Samples.ImageService"> <endpoint name="RelayEndpoint" contract="Microsoft.ServiceBus.Samples.IImageContract" binding="webHttpRelayBinding" bindingConfiguration="customBinding" behaviorConfiguration="sharedSecretClientCredentials" address="" /> </service> </services> <behaviors> <!-- Specify service and endpoint behaviors here. --> </behaviors> </system.serviceModel>
The following example illustrates the use of WebHttpRelayBinding programmatically with custom settings. The custom binding has client authentication turned off, which means that the client is not required to present a security token to the Windows Azure Service Bus. This example is a modified version of the WebHttp SDK sample, which specifies the binding for the service endpoint programmatically instead of specifying it in the application configuration file. The WebHttp SDK sample can be found in the SDK install directory under \Samples\ServiceBus\ExploringFeatures\Bindings\WebHttp.
This example starts by specifying the credentials the service application is 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 web service host. After starting the web service, the user can use a browser to get the image that the service exposes at the specified URL.
// Configure the credentials for the service and client endpoints 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. WebHttpRelayBinding binding = new WebHttpRelayBinding(); binding.Security.RelayClientAuthenticationType = RelayClientAuthenticationType.None; // Get the service URI. Uri address = ServiceBusEnvironment.CreateServiceUri("https", serviceNamespace, "Image"); // Create the web service host. WebServiceHost host = new WebServiceHost(typeof(ImageService), address); // Add the service endpoint with the WebHttpRelayBinding binding. host.AddServiceEndpoint(typeof(IImageContract), binding, address); // Add the credentials through the endpoint behavior. host.Description.Endpoints.Behaviors.Add(relayCredentials); // Start the service. host.Open(); Console.WriteLine("Copy the following address into a browser to see the image: "); Console.WriteLine(address + "GetImage"); Console.WriteLine(); Console.WriteLine("Press [Enter] to exit"); Console.ReadLine(); host.Close();