IBindingDeliveryCapabilities 介面
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
定義綁定必須實作的介面,以描述並宣告客戶端與服務可能所需的功能。
public interface class IBindingDeliveryCapabilities
public interface IBindingDeliveryCapabilities
type IBindingDeliveryCapabilities = interface
Public Interface IBindingDeliveryCapabilities
範例
以下範例要求必須 CalculatorService 使用 WSHttpBinding 與有序訊息傳遞。 此綁定預設不使用可靠會話與排隊交付,但可啟用。
<!-- Here is the configuration for a CalculatorService using a WSHttpBinding with ordered message delivery required. -->
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service
type="Microsoft.ServiceModel.Samples.CalculatorService">
<!-- Use base address provided by host and a WSHttpBinding named "Binding1" -->
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="Binding1"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="Binding1">
<!-- The next element enables a ReliableSession and required ordered delivery-->
<reliableSession enabled="true" ordered="true"/>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
</configuration>
// The CalculatorService configuration has enabled a reliable session
// with ordered delivery set to true. This means that the binding
// requirement for ordered delivery specified by the
// BindingRequirementsAttribute on the CalculatorService class
// implemented below will be satisfied by this WSHttpBinding.
using System;
using System.ServiceModel;
[ServiceContract]
interface ICalculatorService
{
[OperationBehavior()]
int Add(int a, int b);
[OperationContract]
int Subtract(int a, int b);
}
[BindingRequirements(
QueuedDeliveryRequirements=RequirementsMode.Disallow,
RequireOrderedDelivery=true
)]
class CalculatorService: ICalculatorService
{
public int Add(int a, int b)
{
Console.WriteLine("Add called.");
return a + b;
}
public int Subtract(int a, int b)
{
Console.WriteLine("Subtract called.");
return a - b;
}
public int Multiply(int a, int b)
{
return a * b;
}
}
備註
IBindingDeliveryCapabilities若客戶端與服務若要在合約中規定所需功能由綁定提供,則該介面必須透過綁定來實作。
屬性
| 名稱 | Description |
|---|---|
| AssuresOrderedDelivery |
會獲得一個值,表示綁定是否能保證依傳送順序傳遞訊息。 |
| QueuedDelivery |
會獲得一個值,表示綁定是否能支援排隊式訊息的傳遞。 |