MsmqIntegrationBinding Class

Definition

MsmqIntegrationBinding 類別會將 Microsoft Message Queuing (MSMQ) 訊息對應至 Windows Communication Foundation (WCF) 訊息。The MsmqIntegrationBinding class maps Microsoft Message Queuing (MSMQ) messages to Windows Communication Foundation (WCF) messages.

public ref class MsmqIntegrationBinding : System::ServiceModel::MsmqBindingBase
public class MsmqIntegrationBinding : System.ServiceModel.MsmqBindingBase
type MsmqIntegrationBinding = class
    inherit MsmqBindingBase
Public Class MsmqIntegrationBinding
Inherits MsmqBindingBase
Inheritance
MsmqIntegrationBinding

Examples

下列組態檔片段說明如何在用戶端上設定 MsmqIntegrationBinding 繫結:The following configuration file snippet illustrates how to configure the MsmqIntegrationBinding binding on the client:

下列組態檔片段說明如何在服務上設定 MsmqIntegrationBinding 繫結:The following configuration file snippet illustrates how to configure the MsmqIntegrationBinding binding on the service:

[ServiceContract(Namespace = "http://Microsoft.ServiceModel.Samples")]
[ServiceKnownType(typeof(PurchaseOrder))]
public interface IOrderProcessor
{
    [OperationContract(IsOneWay = true, Action = "*")]
    void SubmitPurchaseOrder(MsmqMessage<PurchaseOrder> msg);
}
<ServiceContract(Namespace:="http:'Microsoft.ServiceModel.Samples")> _
<ServiceKnownType(GetType(PurchaseOrder))> _
Public Interface IOrderProcessor
    <OperationContract(IsOneWay:=True, Action:="*")> _
    Sub SubmitPurchaseOrder(ByVal msg As MsmqMessage(Of PurchaseOrder))
End Interface

下列程式碼說明如何以程式設計的方式使用服務上的 MsmqIntegrationBinding 繫結:The following code illustrates how to use the MsmqIntegrationBinding binding on the service programmatically:

public class OrderProcessorService : IOrderProcessor
{
    [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
    public void SubmitPurchaseOrder(MsmqMessage<PurchaseOrder> ordermsg)
    {
        PurchaseOrder po = (PurchaseOrder)ordermsg.Body;
        Random statusIndexer = new Random();
        po.Status = (OrderStates)statusIndexer.Next(3);
        Console.WriteLine("Processing {0} ", po);
    }

    // Host the service within this EXE console application.
public static void Main()
{
    // Get base address from appsettings in configuration.
    Uri baseAddress = new Uri(ConfigurationManager.AppSettings["baseAddress"]);

    // Create a ServiceHost for the CalculatorService type and provide the base address.
    using (ServiceHost serviceHost = new ServiceHost(typeof(IOrderProcessor), baseAddress))
    {
    // Open the ServiceHostBase to create listeners and start listening for messages.
        serviceHost.Open();

    // The service can now be accessed.
        Console.WriteLine("The service is ready.");
        Console.WriteLine("The service is running in the following account: {0}", WindowsIdentity.GetCurrent().Name);
        Console.WriteLine("Press <ENTER> to terminate service.");
        Console.WriteLine();
        Console.ReadLine();

    // Close the ServiceHostBase to shutdown the service.
        serviceHost.Close();
    }
}
}
Public Class OrderProcessorService
    Implements IOrderProcessor

    <OperationBehavior(TransactionScopeRequired:=True, TransactionAutoComplete:=True)> _
    Public Sub SubmitPurchaseOrder(ByVal ordermsg As MsmqMessage(Of PurchaseOrder)) Implements IOrderProcessor.SubmitPurchaseOrder
        Dim po As PurchaseOrder = ordermsg.Body
        Dim statusIndexer As New Random()
        po.Status = statusIndexer.Next(3)
        Console.WriteLine("Processing {0} ", po)
    End Sub
End Class

下列程式碼說明如何以程式設計的方式使用用戶端上的 MsmqIntegrationBinding 繫結:The following code illustrates how to use the MsmqIntegrationBinding binding on the client programmatically:

MsmqIntegrationBinding binding = new MsmqIntegrationBinding();
EndpointAddress address = new EndpointAddress("msmq.formatname:DIRECT=OS:.\\private$\\Orders");
ChannelFactory<IOrderProcessor> channelFactory = new ChannelFactory<IOrderProcessor>(binding, address);
IOrderProcessor channel = channelFactory.CreateChannel();

PurchaseOrder po = new PurchaseOrder();
po.customerId = "somecustomer.com";
po.poNumber = Guid.NewGuid().ToString();

PurchaseOrderLineItem lineItem1 = new PurchaseOrderLineItem();
lineItem1.productId = "Blue Widget";
lineItem1.quantity = 54;
lineItem1.unitCost = 29.99F;

PurchaseOrderLineItem lineItem2 = new PurchaseOrderLineItem();
lineItem2.productId = "Red Widget";
lineItem2.quantity = 890;
lineItem2.unitCost = 45.89F;

po.orderLineItems = new PurchaseOrderLineItem[2];
po.orderLineItems[0] = lineItem1;
po.orderLineItems[1] = lineItem2;

MsmqMessage<PurchaseOrder> ordermsg = new MsmqMessage<PurchaseOrder>(po);
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
{
    channel.SubmitPurchaseOrder(ordermsg);
    scope.Complete();
}
Console.WriteLine("Order has been submitted:{0}", po);
Dim binding As New MsmqIntegrationBinding()
Dim address As New EndpointAddress("msmq.formatname:DIRECT=OS:.\\private$\\Orders")
Dim channelFactory As New ChannelFactory(Of IOrderProcessor)(binding, address)
Dim channel As IOrderProcessor = channelFactory.CreateChannel()

Dim po As New PurchaseOrder()
po.customerId = "somecustomer.com"
po.poNumber = Guid.NewGuid().ToString()

Dim lineItem1 As New PurchaseOrderLineItem()
lineItem1.productId = "Blue Widget"
lineItem1.quantity = 54
lineItem1.unitCost = 29.99F

Dim lineItem2 = New PurchaseOrderLineItem()
lineItem2.productId = "Red Widget"
lineItem2.quantity = 890
lineItem2.unitCost = 45.89F

Dim lineItems(1) As PurchaseOrderLineItem
lineItems(0) = lineItem1
lineItems(1) = lineItem2

po.orderLineItems = lineItems

Dim ordermsg As MsmqMessage(Of PurchaseOrder) = New MsmqMessage(Of PurchaseOrder)(po)
Using scope As New TransactionScope(TransactionScopeOption.Required)
    channel.SubmitPurchaseOrder(ordermsg)
    scope.Complete()
End Using
Console.WriteLine("Order has been submitted:{0}", po)

Remarks

Important

使用不信任的資料呼叫此類別的方法,會造成安全性上的風險。Calling methods from this class with untrusted data is a security risk. 呼叫此類別的方法時,請一律使用信任的資料。Call the methods from this class only with trusted data. 如需詳細資訊,請參閱資料驗證For more information, see Data Validation.

這個系結可讓 WCF 應用程式在現有的 MSMQ 應用程式(使用 COM、原生C++ api 或System.Messaging命名空間中定義的類型)之間傳送和接收訊息。This binding can be used to enable WCF applications to send and receive messages to and from existing MSMQ applications that use COM, native C++ APIs or the types defined in the System.Messaging namespace.

Constructors

MsmqIntegrationBinding()

初始化 MsmqIntegrationBinding 類別的新執行個體。Initializes a new instance of the MsmqIntegrationBinding class.

MsmqIntegrationBinding(MsmqIntegrationSecurityMode)

使用指定的 MsmqIntegrationBinding 來初始化 MsmqIntegrationSecurityMode 類別的新執行個體。Initializes a new instance of the MsmqIntegrationBinding class by using the specified MsmqIntegrationSecurityMode.

MsmqIntegrationBinding(String)

從指定的組態繫結項目設定,初始化 MsmqIntegrationBinding 類別的新執行個體。Initializes a new instance of the MsmqIntegrationBinding class from the settings of a specified configuration binding element.

Properties

CloseTimeout

取得或設定針對連線所提供的時間間隔 (此連線要在傳輸引發例外狀況之前關閉)。Gets or sets the interval of time provided for a connection to close before the transport raises an exception.

(Inherited from Binding)
CustomDeadLetterQueue

取得或設定 URI,其中包含每個應用程式寄不出的信件佇列的位置,所有已過期、無法傳輸或傳遞的訊息都會放到該佇列中。Gets or sets a URI that contains the location of the dead-letter queue for each application, where messages that have expired or that have failed transfer or delivery are placed.

(Inherited from MsmqBindingBase)
DeadLetterQueue

取得或設定列舉值,這個值會指出要使用之寄不出的信件佇列類型。Gets or sets an enumeration value that indicates the type of dead-letter queue to use.

(Inherited from MsmqBindingBase)
Durable

取得或設定值,這個值會指出由這個繫結處理的訊息是否具有永久性或變動性。Gets or sets a value that indicates whether the messages processed by this binding are durable or volatile.

(Inherited from MsmqBindingBase)
ExactlyOnce

取得或設定值,這個值會指出由這個繫結處理的訊息是否會確實接收一次。Gets or sets a value that indicates whether messages processed by this binding are received exactly once.

(Inherited from MsmqBindingBase)
MaxReceivedMessageSize

取得或設定這個繫結所處理之訊息的大小上限 (以位元組為單位)。Gets or sets the maximum size, in bytes, for a message that is processed by this binding.

(Inherited from MsmqBindingBase)
MaxRetryCycles

取得或設定嘗試傳遞訊息至接收應用程式的重試循環次數上限。Gets or sets the maximum number of retry cycles to attempt delivery of messages to the receiving application.

(Inherited from MsmqBindingBase)
MessageVersion

取得用戶端所使用的訊息版本及使用繫結所設定的服務。Gets the message version used by clients and services configured with the binding.

(Inherited from Binding)
Name

取得或設定繫結的名稱。Gets or sets the name of the binding.

(Inherited from Binding)
Namespace

取得或設定繫結的 XML 命名空間。Gets or sets the XML namespace of the binding.

(Inherited from Binding)
OpenTimeout

取得或設定針對連線所提供的時間間隔 (此連線要在傳輸引發例外狀況之前開啟)。Gets or sets the interval of time provided for a connection to open before the transport raises an exception.

(Inherited from Binding)
ReceiveContextEnabled

取得或設定值,這個值表示是否已要求接收內容行為。Gets or sets a value that indicates whether the receive context behavior is requested.

(Inherited from MsmqBindingBase)
ReceiveErrorHandling

取得或設定列舉值,這個值會指定如何處理有害的訊息。Gets or sets an enumeration value that specifies how poison messages are handled.

(Inherited from MsmqBindingBase)
ReceiveRetryCount

取得或設定從應用程式佇列讀取之訊息的立即傳遞嘗試次數上限。Gets or sets the maximum number of immediate delivery attempts on a message that is read from the application queue.

(Inherited from MsmqBindingBase)
ReceiveTimeout

取得或設定連線中斷之前,可以維持非作用狀態的時間間隔 (在此期間未接收應用程式訊息)。Gets or sets the interval of time that a connection can remain inactive, during which no application messages are received, before it is dropped.

(Inherited from Binding)
RetryCycleDelay

取得或設定值,這個值會指出嘗試傳遞無法立即傳遞之訊息時,重試循環之間的時間延遲。Gets or sets a value that indicates the time delay between retry cycles when attempting to deliver a message that cannot be delivered immediately.

(Inherited from MsmqBindingBase)
Scheme

傳回這個繫結的配置。Returns the scheme for this binding.

(Inherited from MsmqBindingBase)
Security

取得與這個繫結關聯的 MsmqIntegrationSecurityGets the MsmqIntegrationSecurity that is associated with this binding.

SendTimeout

取得或設定針對寫入作業所提供的時間間隔 (此作業要在傳輸引發例外狀況之前完成)。Gets or sets the interval of time provided for a write operation to complete before the transport raises an exception.

(Inherited from Binding)
SerializationFormat

取得或設定要用於序列化或還原序列化訊息的序列化格式。Gets or sets the serialization format to be used to serialize or deserialize the message.

TimeToLive

取得或設定時間間隔,這個間隔會指出由此繫結所處理之訊息在到期前可保留在佇列中的時間長度。Gets or sets the interval of time that indicates how long the messages processed by this binding can be in the queue before they expire.

(Inherited from MsmqBindingBase)
UseMsmqTracing

取得或設定值,這個值會指出是否應追蹤由此繫結處理的訊息。Gets or sets a value that indicates whether messages processed by this binding should be traced.

(Inherited from MsmqBindingBase)
UseSourceJournal

取得或設定值,此值會指出是否要將此繫結處理之訊息的複本儲存在來源日誌佇列。Gets or sets a value that indicates whether copies of messages processed by this binding should be stored in the source journal queue.

(Inherited from MsmqBindingBase)
ValidityDuration

取得或設定值,這個值會指定接收內容功能鎖定訊息的持續期間。Gets or sets a value that specifies the duration a message will be locked by the receive context feature.

(Inherited from MsmqBindingBase)

Methods

BuildChannelFactory<TChannel>(BindingParameterCollection)

在用戶端上建置通道處理站堆疊,此堆疊會建立指定的通道型別,並滿足繫結參數集合所指定的功能。Builds the channel factory stack on the client that creates a specified type of channel and that satisfies the features specified by a collection of binding parameters.

(Inherited from Binding)
BuildChannelFactory<TChannel>(Object[])

在用戶端上建置通道處理站堆疊,此堆疊會建立指定的通道型別,並滿足物件陣列所指定的功能。Builds the channel factory stack on the client that creates a specified type of channel and that satisfies the features specified by an object array.

(Inherited from Binding)
BuildChannelListener<TChannel>(BindingParameterCollection)

在服務上建置通道接聽程式,此接聽程式會接受指定的通道型別,並滿足繫結參數集合所指定的功能。Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified by a collection of binding parameters.

(Inherited from Binding)
BuildChannelListener<TChannel>(Object[])

在服務上建置通道接聽程式,此接聽程式可接受指定的通道型別並滿足指定的功能。Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified.

(Inherited from Binding)
BuildChannelListener<TChannel>(Uri, BindingParameterCollection)

在服務上建置通道接聽程式,此接聽程式可接受指定的通道型別並滿足指定的功能。Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified.

(Inherited from Binding)
BuildChannelListener<TChannel>(Uri, Object[])

在服務上建置通道接聽程式,此接聽程式可接受指定的通道型別並滿足指定的功能。Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified.

(Inherited from Binding)
BuildChannelListener<TChannel>(Uri, String, BindingParameterCollection)

在服務上建置通道接聽程式,此接聽程式可接受指定的通道型別並滿足指定的功能。Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified.

(Inherited from Binding)
BuildChannelListener<TChannel>(Uri, String, ListenUriMode, BindingParameterCollection)

在服務上建置通道接聽程式,此接聽程式可接受指定的通道型別並滿足指定的功能。Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified.

(Inherited from Binding)
BuildChannelListener<TChannel>(Uri, String, ListenUriMode, Object[])

在服務上建置通道接聽程式,此接聽程式可接受指定的通道型別並滿足指定的功能。Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified.

(Inherited from Binding)
BuildChannelListener<TChannel>(Uri, String, Object[])

在服務上建置通道接聽程式,此接聽程式可接受指定的通道型別並滿足指定的功能。Builds the channel listener on the service that accepts a specified type of channel and that satisfies the features specified.

(Inherited from Binding)
CanBuildChannelFactory<TChannel>(BindingParameterCollection)

傳回值,這個值指出目前的繫結是否可以在用戶端上建置滿足指定之繫結參數集合的通道處理站堆疊。Returns a value that indicates whether the current binding can build a channel factory stack on the client that satisfies the collection of binding parameters specified.

(Inherited from Binding)
CanBuildChannelFactory<TChannel>(Object[])

傳回值,這個值指出目前的繫結是否可以在用戶端上建置滿足物件陣列指定之需求的通道處理站堆疊。Returns a value that indicates whether the current binding can build a channel factory stack on the client that satisfies the requirements specified by an object array.

(Inherited from Binding)
CanBuildChannelListener<TChannel>(BindingParameterCollection)

傳回值,這個值指出目前的繫結是否可以在服務上建置滿足指定之繫結參數集合的通道接聽程式堆疊。Returns a value that indicates whether the current binding can build a channel listener stack on the service that satisfies the collection of binding parameters specified.

(Inherited from Binding)
CanBuildChannelListener<TChannel>(Object[])

傳回值,這個值指出目前的繫結是否可以在服務上建置滿足物件陣列中指定之準則的通道接聽程式堆疊。Returns a value that indicates whether the current binding can build a channel listener stack on the service that satisfies the criteria specified in an array of objects.

(Inherited from Binding)
CreateBindingElements()

傳回基本設定檔堆疊中的繫結項目。Returns the binding elements in the basic profile stack.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetProperty<T>(BindingParameterCollection)

從繫結堆疊的適當層次中,傳回要求的型別物件 (如果有)。Returns a typed object requested, if present, from the appropriate layer in the binding stack.

(Inherited from Binding)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(Inherited from Object)
ShouldSerializeName()

傳回繫結的名稱是否應該序列化。Returns whether the name of the binding should be serialized.

(Inherited from Binding)
ShouldSerializeNamespace()

傳回繫結的命名空間是否應該序列化。Returns whether the namespace of the binding should be serialized.

(Inherited from Binding)
ShouldSerializeSecurity()

取得一個值,這個值會指定是否應該序列化安全性資訊。Gets a value that specifies whether security information should be serialized.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

IBindingRuntimePreferences.ReceiveSynchronously

取得值,這個值指出以同步還是非同步方式處理傳入要求可以比較有效率。Gets a value that indicates whether incoming requests can be handled more efficiently synchronously or asynchronously.

(Inherited from MsmqBindingBase)

Applies to