This documentation is archived and is not being maintained.

MsmqIntegrationBinding Class

The MsmqIntegrationBinding class maps Microsoft Message Queuing (MSMQ) messages to Windows Communication Foundation (WCF) messages.

Namespace: System.ServiceModel.MsmqIntegration
Assembly: System.ServiceModel (in system.servicemodel.dll)

public class MsmqIntegrationBinding : MsmqBindingBase
public class MsmqIntegrationBinding extends MsmqBindingBase
public class MsmqIntegrationBinding extends MsmqBindingBase
Not applicable.

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:

[ServiceContract(Namespace = "http://Microsoft.ServiceModel.Samples")]
public interface IOrderProcessor
    [OperationContract(IsOneWay = true, Action = "*")]
    void SubmitPurchaseOrder(MsmqMessage<PurchaseOrder> msg);

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.

    // 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.");

    // Close the ServiceHostBase to shutdown the service.


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 = "";
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))
Console.WriteLine("Order has been submitted:{0}", po);


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0