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)
Initializes a new instance of theclass.
Initializes a new instance of theclass using the specified type of security and relay client authentication.
Initializes a new instance of theclass using the specified configuration name.
Gets or sets a value that specifies whether cookies are allowed in the messages sent via the.
Gets or sets the content type mapper.
Gets the SOAP envelope version.
Gets or sets the comparison mode used on the host name.
Gets or sets whether the relay binding is dynamic.
Gets or sets the maximum buffer pool size used by the transport.
Gets or sets the maximum buffer size supported by the transport.
Gets or sets the maximum allowable message size that can be received.
Gets or sets a URI that contains the address of the proxy to use for HTTP requests.
Gets or sets xml reader quotas on the messages processed.
Gets the scheme for the endpoints used with the binding.(Overrides Binding.Scheme.)
Gets the security settings for the current instance.
Gets or sets the transfer mode.
Gets or sets a value that indicates whether the machine-wide proxy settings are used rather than the user specific settings.
Gets or sets the character encoding that is used to write the message text.
The WS2007HttpRelayBinding would be more appropriate.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
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 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 Service Bus. This example is a modified version of the WebHttp sample, which specifies the binding for the service endpoint programmatically instead of specifying it in the application configuration file.
The example starts by specifying the credentials the service application is expected to send to 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.TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider(keyName, key); // 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();
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.