匯出 (0) 列印
全部展開
本主題尚未接受評分 - 為這個主題評分

WebHttpRelayBinding 類別

用來設定 Web 服務端點的繫結,這些服務是透過 HTTP 要求進行公開,而不是透過 SOAP 訊息。

System..::..Object
  System.ServiceModel.Channels..::..Binding
    Microsoft.ServiceBus..::..WebHttpRelayBinding

命名空間:  Microsoft.ServiceBus
組件:  Microsoft.ServiceBus (在 Microsoft.ServiceBus.dll 中)
public class WebHttpRelayBinding : Binding, 
	IBindingRuntimePreferences

WebHttpRelayBinding 型別公開下列成員。

  名稱說明
公用方法WebHttpRelayBinding()()()()初始化 WebHttpRelayBinding 類別的新執行個體。
公用方法WebHttpRelayBinding(String)使用指定的組態名稱,初始化 WebHttpRelayBinding 類別的新執行個體。
公用方法WebHttpRelayBinding(EndToEndWebHttpSecurityMode, RelayClientAuthenticationType)使用指定的安全性和轉送用戶端驗證類型,初始化 WebHttpRelayBinding 類別的新執行個體。
上層
  名稱說明
公用屬性AllowCookies取得或設定值,這個值指定透過 WebHttpRelayBinding 傳送的訊息中是否允許 Cookie。
公用屬性CloseTimeout (繼承自 Binding。)
公用屬性ContentTypeMapper取得或設定內容類型對應程式。
公用屬性EnvelopeVersion取得 SOAP 信封版本。
公用屬性HostNameComparisonMode取得或設定用於主機名稱的比較模式。
公用屬性IsDynamicGets or sets whether the relay binding is dynamic.
公用屬性MaxBufferPoolSize取得或設定傳輸所使用的緩衝集區大小上限。
公用屬性MaxBufferSize取得或設定傳輸所支援的緩衝區大小上限。
公用屬性MaxReceivedMessageSize取得或設定可允許接收的訊息大小上限。
公用屬性MessageVersion (繼承自 Binding。)
公用屬性Name (繼承自 Binding。)
公用屬性Namespace (繼承自 Binding。)
公用屬性OpenTimeout (繼承自 Binding。)
公用屬性ProxyAddress取得或設定 URI,此 URI 包含用於 HTTP 要求的 Proxy 位址。
公用屬性ReaderQuotas取得或設定所處理之訊息上的 XML 讀取器配額。
公用屬性ReceiveTimeout (繼承自 Binding。)
公用屬性Scheme取得與繫結搭配使用的端點配置。 (覆寫 Binding..::..Scheme。)
公用屬性Security取得目前執行個體的安全性設定。
公用屬性SendTimeout (繼承自 Binding。)
公用屬性TransferMode取得或設定傳輸模式。
公用屬性UseDefaultWebProxy取得或設定值,此值指出是否使用整部機器的 Proxy 設定,而非使用者特定的設定。
公用屬性WriteEncoding取得或設定用來撰寫訊息文字的字元編碼。
上層
  名稱說明
公用方法BuildChannelFactory<(Of <<'(TChannel>)>>)(array<Object>[]()[][]) (繼承自 Binding。)
公用方法BuildChannelFactory<(Of <<'(TChannel>)>>)(BindingParameterCollection) (繼承自 Binding。)
公用方法BuildChannelListener<(Of <<'(TChannel>)>>)(array<Object>[]()[][]) (繼承自 Binding。)
公用方法BuildChannelListener<(Of <<'(TChannel>)>>)(BindingParameterCollection) (繼承自 Binding。)
公用方法BuildChannelListener<(Of <<'(TChannel>)>>)(Uri, array<Object>[]()[][]) (繼承自 Binding。)
公用方法BuildChannelListener<(Of <<'(TChannel>)>>)(Uri, BindingParameterCollection) (繼承自 Binding。)
公用方法BuildChannelListener<(Of <<'(TChannel>)>>)(Uri, String, array<Object>[]()[][]) (繼承自 Binding。)
公用方法BuildChannelListener<(Of <<'(TChannel>)>>)(Uri, String, BindingParameterCollection) (繼承自 Binding。)
公用方法BuildChannelListener<(Of <<'(TChannel>)>>)(Uri, String, ListenUriMode, array<Object>[]()[][]) (繼承自 Binding。)
公用方法BuildChannelListener<(Of <<'(TChannel>)>>)(Uri, String, ListenUriMode, BindingParameterCollection) (繼承自 Binding。)
公用方法CanBuildChannelFactory<(Of <<'(TChannel>)>>)(array<Object>[]()[][]) (繼承自 Binding。)
公用方法CanBuildChannelFactory<(Of <<'(TChannel>)>>)(BindingParameterCollection) (繼承自 Binding。)
公用方法CanBuildChannelListener<(Of <<'(TChannel>)>>)(array<Object>[]()[][]) (繼承自 Binding。)
公用方法CanBuildChannelListener<(Of <<'(TChannel>)>>)(BindingParameterCollection) (繼承自 Binding。)
公用方法CreateBindingElements利用繫結的繫結元素建立集合。 (覆寫 Binding..::..CreateBindingElements()()()()。)
公用方法Equals (繼承自 Object。)
受保護的方法Finalize (繼承自 Object。)
公用方法GetHashCode (繼承自 Object。)
公用方法GetProperty<(Of <<'(T>)>>) (繼承自 Binding。)
公用方法GetType (繼承自 Object。)
受保護的方法MemberwiseClone (繼承自 Object。)
公用方法ShouldSerializeName (繼承自 Binding。)
公用方法ShouldSerializeNamespace (繼承自 Binding。)
公用方法ToString (繼承自 Object。)
上層
  名稱說明
明確介面實作私用屬性IBindingRuntimePreferences..::..ReceiveSynchronously取得值,此值指出以同步或非同步方式處理傳入要求。
上層

The WebHttpRelayBinding 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 WebHttpRelayBinding. 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[0].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();
這個型別的任何公用 static (在 Visual Basic 中為 Shared) 成員都是執行緒安全的。並不是所有的執行個體成員都保證可以用於所有的執行緒。
本文對您有任何幫助嗎?
(剩餘 1500 個字元)
感謝您提供意見

社群新增項目

新增
Microsoft 正展開一份線上問卷調查,了解您對於 MSDN 網站的看法。 如果您選擇參加,您離開 MSDN 網站時即會顯示線上問卷調查。

您是否想要參加?
顯示:
© 2014 Microsoft. 著作權所有,並保留一切權利。