2 // Copyright (c) Microsoft Corporation. All Rights Reserved.
5 using System
.Collections
.Generic
;
7 using System
.Transactions
;
8 using System
.ServiceModel
.MsmqIntegration
;
10 namespace Microsoft
.ServiceModel
.Samples
14 static void Main(string[] args
)
16 // Create the purchase order
17 PurchaseOrder po
= new PurchaseOrder();
18 po
.customerId
= "somecustomer.com";
19 po
.poNumber
= Guid
.NewGuid().ToString();
21 PurchaseOrderLineItem lineItem1
= new PurchaseOrderLineItem();
22 lineItem1
.productId
= "Blue Widget";
23 lineItem1
.quantity
= 54;
24 lineItem1
.unitCost
= 29.99F
;
26 PurchaseOrderLineItem lineItem2
= new PurchaseOrderLineItem();
27 lineItem2
.productId
= "Red Widget";
28 lineItem2
.quantity
= 890;
29 lineItem2
.unitCost
= 45.89F
;
31 po
.orderLineItems
= new PurchaseOrderLineItem
[2];
32 po
.orderLineItems
[0] = lineItem1
;
33 po
.orderLineItems
[1] = lineItem2
;
35 OrderProcessorClient client
= new OrderProcessorClient("OrderResponseEndpoint");
37 MsmqMessage
<PurchaseOrder
> ordermsg
= new MsmqMessage
<PurchaseOrder
>(po
);
38 using (TransactionScope scope
= new TransactionScope(TransactionScopeOption
.Required
))
40 client
.SubmitPurchaseOrder(ordermsg
);
43 Console
.WriteLine("Order has been submitted:{0}", po
);
45 //Closing the client gracefully closes the connection and cleans up resources
49 Console
.WriteLine("Press <ENTER> to terminate client.");