// Get the MessageVersion from a Custom binding public static void GetMessageVersion() { MessageVersion version = null; BindingElement[] bindingElements = new BindingElement[2]; bindingElements[0] = new TextMessageEncodingBindingElement(); bindingElements[1] = new HttpTransportBindingElement(); CustomBinding binding = new CustomBinding(bindingElements); version = binding.MessageVersion; string expected = "Soap12 (http://www.w3.org/2003/05/soap-envelope) Addressing10 (http://www.w3.org/2005/08/addressing)"; string actual = version.ToString(); Assert.Equal <string>(expected, actual); }
protected override string GenerateId(string path, MessageVersion messageVersion, bool reusable, IReadOnlyDictionary <string, object> properties) { var parts = new List <string> { typeof(TChannel).FullName, messageVersion.ToString(), path ?? "/" }; foreach (var pair in properties) { parts.Add($"{pair.Key}:{pair.Value}"); } if (!reusable) { parts.Add(Guid.NewGuid().ToString()); } return(string.Join("__", parts)); }
static void Main(string[] args) { // <Snippet0> MessageVersion msgVersion = MessageVersion.Default; // </Snippet0> // <Snippet1> AddressingVersion addrVersion = msgVersion.Addressing; // </Snippet1> // <Snippet2> EnvelopeVersion envVersion = msgVersion.Envelope; // </Snippet2> // <Snippet3> msgVersion.ToString(); // </Snippet3> // <Snippet4> MessageVersion msgVersion2 = MessageVersion.None; // </Snippet4> // <Snippet5> msgVersion = MessageVersion.Soap11; // </Snippet5> // <Snippet6> msgVersion = MessageVersion.Soap11WSAddressing10; // </Snippet6> // <Snippet7> msgVersion = MessageVersion.Soap11WSAddressingAugust2004; // </Snippet7> // <Snippet8> msgVersion = MessageVersion.Soap12; // </Snippet8> // <Snippet9> msgVersion = MessageVersion.Soap12WSAddressing10; // </Snippet9> // <Snippet10> msgVersion = MessageVersion.Soap12WSAddressingAugust2004; // </Snippet10> // <Snippet11> msgVersion = MessageVersion.CreateVersion(envVersion); // </Snippet11> // <Snippet12> msgVersion = MessageVersion.CreateVersion(envVersion, addrVersion); // </Snippet12> // <Snippet13> msgVersion.Equals(msgVersion2); // </Snippet13> // <Snippet14> msgVersion.GetHashCode(); // </Snippet14> }
protected override void OnWriteStartHeader(XmlDictionaryWriter writer, MessageVersion messageVersion) { if (!IsMessageVersionSupported(messageVersion)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.GetString(SR.MessageHeaderVersionNotSupported, String.Format(CultureInfo.InvariantCulture, "{0}:{1}", this.Namespace, this.Name), version.ToString()), "version")); } this.headerXml.WriteHeaderElement(writer); WriteHeaderAttributes(writer, messageVersion); this.headerXml.WriteHeaderId(writer); }