static void EnsureMessageEncoding(WsdlEndpointConversionContext context, MessageEncodingBindingElement encodingBindingElement) { EnvelopeVersion soapVersion = SoapHelper.GetSoapVersion(context.WsdlBinding); AddressingVersion addressingVersion; if (encodingBindingElement == null) { encodingBindingElement = new TextMessageEncodingBindingElement(); ConvertToCustomBinding(context).Elements.Add(encodingBindingElement); addressingVersion = AddressingVersion.None; } else { if (soapVersion == EnvelopeVersion.None) { addressingVersion = AddressingVersion.None; } else { addressingVersion = encodingBindingElement.MessageVersion.Addressing; } } MessageVersion newMessageVersion = MessageVersion.CreateVersion(soapVersion, addressingVersion); if (!encodingBindingElement.MessageVersion.IsMatch(newMessageVersion)) { ConvertToCustomBinding(context).Elements.Find <MessageEncodingBindingElement>().MessageVersion = MessageVersion.CreateVersion(soapVersion, addressingVersion); } }