MsmqIntegrationBinding Class
The MsmqIntegrationBinding class maps Microsoft Message Queuing (MSMQ) messages to Windows Communication Foundation (WCF) messages.
Assembly: System.ServiceModel (in System.ServiceModel.dll)
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.
The following configuration file snippet illustrates how to configure the MsmqIntegrationBinding binding on the client:
The following configuration file snippet illustrates how to configure the MsmqIntegrationBinding binding on the service:
The following code illustrates how to use the MsmqIntegrationBinding binding on the service programmatically:
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
The following code illustrates how to use the MsmqIntegrationBinding binding on the client programmatically:
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(2) 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)
System.ServiceModel.Channels.Binding
System.ServiceModel.MsmqBindingBase
System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.