2 // System.ServiceModel.MessageVersion.cs
4 // Author: Duncan Mak (duncan@novell.com)
6 // Copyright (C) 2005 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;
31 namespace System.ServiceModel.Channels {
33 public sealed class MessageVersion
35 EnvelopeVersion envelope;
36 AddressingVersion addressing;
38 static MessageVersion ()
40 None = new MessageVersion (EnvelopeVersion.None, AddressingVersion.None);
41 Soap11 = new MessageVersion (EnvelopeVersion.Soap11, AddressingVersion.None);
42 Soap12WSAddressing10 = new MessageVersion (EnvelopeVersion.Soap12, AddressingVersion.WSAddressing10);
44 Soap12 = new MessageVersion (EnvelopeVersion.Soap12, AddressingVersion.None);
45 Soap11WSAddressing10 = new MessageVersion (EnvelopeVersion.Soap11, AddressingVersion.WSAddressing10);
46 Soap11WSAddressingAugust2004 = new MessageVersion (EnvelopeVersion.Soap11, AddressingVersion.WSAddressingAugust2004);
47 Soap12WSAddressingAugust2004 = new MessageVersion (EnvelopeVersion.Soap12, AddressingVersion.WSAddressingAugust2004);
50 MessageVersion (EnvelopeVersion envelope, AddressingVersion addressing)
52 this.envelope = envelope;
53 this.addressing = addressing;
56 public static MessageVersion CreateVersion (EnvelopeVersion envelope_version)
58 return CreateVersion (envelope_version,
59 AddressingVersion.WSAddressing10);
62 public static MessageVersion CreateVersion (EnvelopeVersion envelope_version,
63 AddressingVersion addressing_version)
65 if (envelope_version == EnvelopeVersion.None && addressing_version == AddressingVersion.None)
67 if (envelope_version == EnvelopeVersion.Soap11 && addressing_version == AddressingVersion.None)
69 if (envelope_version == EnvelopeVersion.Soap12 && addressing_version == AddressingVersion.WSAddressing10)
70 return Soap12WSAddressing10;
72 if (envelope_version == EnvelopeVersion.Soap12 && addressing_version == AddressingVersion.None)
74 if (envelope_version == EnvelopeVersion.Soap11 && addressing_version == AddressingVersion.WSAddressing10)
75 return Soap11WSAddressing10;
76 if (envelope_version == EnvelopeVersion.Soap11 && addressing_version == AddressingVersion.WSAddressingAugust2004)
77 return Soap11WSAddressingAugust2004;
78 if (envelope_version == EnvelopeVersion.Soap12 && addressing_version == AddressingVersion.WSAddressingAugust2004)
79 return Soap12WSAddressingAugust2004;
80 throw new ArgumentException (string.Format ("EnvelopeVersion {0} cannot be used with AddressingVersion {1}", envelope_version, addressing_version));
83 public override bool Equals (object value)
85 MessageVersion other = value as MessageVersion;
90 return (other.Addressing == this.Addressing) && (other.Envelope == this.Envelope);
93 public override int GetHashCode ()
95 return addressing.GetHashCode () + envelope.GetHashCode ();
98 public override string ToString ()
100 return envelope.ToString () + " " + addressing.ToString ();
103 public AddressingVersion Addressing {
104 get { return addressing; }
107 public static MessageVersion Default {
108 get { return CreateVersion (EnvelopeVersion.Soap12); }
111 public EnvelopeVersion Envelope {
112 get { return envelope; }
115 public static MessageVersion None {
119 public static MessageVersion Soap11 {
123 public static MessageVersion Soap12WSAddressing10 {
127 public static MessageVersion Soap12 {
131 public static MessageVersion Soap11WSAddressing10 {
135 public static MessageVersion Soap11WSAddressingAugust2004 {
139 public static MessageVersion Soap12WSAddressingAugust2004 {