2 // MsmqBindingElementBase.cs
4 // Author: Atsushi Enomoto <atsushi@ximian.com>
6 // Copyright (C) 2007 Novell, Inc (http://www.novell.com)
8 // Permission is hereby granted, free of charge, to any person obtaining
9 // a copy of this software and associated documentation files (the
10 // "Software"), to deal in the Software without restriction, including
11 // without limitation the rights to use, copy, modify, merge, publish,
12 // distribute, sublicense, and/or sell copies of the Software, and to
13 // permit persons to whom the Software is furnished to do so, subject to
14 // the following conditions:
16 // The above copyright notice and this permission notice shall be
17 // included in all copies or substantial portions of the Software.
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using System.ServiceModel;
30 using System.ServiceModel.Description;
33 namespace System.ServiceModel.Channels
35 public abstract class MsmqBindingElementBase : TransportBindingElement,
36 ITransactedBindingElement, IPolicyExportExtension, IWsdlExportExtension
38 Uri custom_dead_letter_queue;
39 DeadLetterQueue dead_letter_queue = DeadLetterQueue.System;
40 bool durable = true, exactly_once = true, tx_enabled, use_msmq_trace, use_source_journal;
41 int max_retry_cycles = 2, receive_retry_count = 5;
42 ReceiveErrorHandling receive_error_handling;
43 TimeSpan retry_cycle_delay = TimeSpan.FromMinutes (30), ttl = TimeSpan.FromDays (1);
44 MsmqTransportSecurity transport_security =
45 new MsmqTransportSecurity ();
47 internal MsmqBindingElementBase ()
51 public Uri CustomDeadLetterQueue {
52 get { return custom_dead_letter_queue; }
53 set { custom_dead_letter_queue = value; }
56 public DeadLetterQueue DeadLetterQueue {
57 get { return dead_letter_queue; }
58 set { dead_letter_queue = value; }
62 get { return durable; }
63 set { durable = value; }
66 public bool ExactlyOnce {
67 get { return exactly_once; }
68 set { exactly_once = value; }
71 public int MaxRetryCycles {
72 get { return max_retry_cycles; }
73 set { max_retry_cycles = value; }
76 public MsmqTransportSecurity MsmqTransportSecurity {
77 get { return transport_security; }
80 public ReceiveErrorHandling ReceiveErrorHandling {
81 get { return receive_error_handling; }
82 set { receive_error_handling = value; }
85 public int ReceiveRetryCount {
86 get { return receive_retry_count; }
87 set { receive_retry_count = value; }
90 public TimeSpan RetryCycleDelay {
91 get { return retry_cycle_delay; }
92 set { retry_cycle_delay = value; }
95 public TimeSpan TimeToLive {
100 public bool TransactedReceiveEnabled {
101 get { return tx_enabled; }
104 public bool UseMsmqTracing {
105 get { return use_msmq_trace; }
106 set { use_msmq_trace = value; }
109 public bool UseSourceJournal {
110 get { return use_source_journal; }
111 set { use_source_journal = value; }
114 public override T GetProperty<T> (BindingContext context)
116 if (typeof (T) is IBindingDeliveryCapabilities)
117 throw new NotImplementedException ();
118 if (typeof (T) is ISecurityCapabilities)
119 throw new NotImplementedException ();
120 return base.GetProperty<T> (context);
123 void IPolicyExportExtension.ExportPolicy (MetadataExporter exporter, PolicyConversionContext context)
125 if (exporter == null)
126 throw new ArgumentNullException ("exporter");
128 throw new ArgumentNullException ("context");
130 PolicyAssertionCollection assertions = context.GetBindingAssertions ();
131 XmlDocument doc = new XmlDocument ();
133 assertions.Add (doc.CreateElement ("wsaw", "UsingAddressing", "http://www.w3.org/2006/05/addressing/wsdl"));
134 assertions.Add (doc.CreateElement ("msmq", "Authenticated", "http://schemas.microsoft.com/ws/06/2004/mspolicy/msmq"));
135 assertions.Add (doc.CreateElement ("msb", "BinaryEncoding",
136 "http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1"));
138 if (transport_security.MsmqAuthenticationMode == MsmqAuthenticationMode.WindowsDomain)
139 assertions.Add (doc.CreateElement ("msmq", "WindowsDomain",
140 "http://schemas.microsoft.com/ws/06/2004/mspolicy/msmq"));
143 assertions.Add (doc.CreateElement ("msmq", "MsmqVolatile",
144 "http://schemas.microsoft.com/ws/06/2004/mspolicy/msmq"));
147 assertions.Add (doc.CreateElement ("msmq", "MsmqBestEffort",
148 "http://schemas.microsoft.com/ws/06/2004/mspolicy/msmq"));
152 void IWsdlExportExtension.ExportContract (WsdlExporter exporter, WsdlContractConversionContext context)
154 throw new NotImplementedException ();
158 void IWsdlExportExtension.ExportEndpoint (WsdlExporter exporter, WsdlEndpointConversionContext endpointContext)
160 throw new NotImplementedException ();