From 792684cb27da59dc9aca5c818b1d599192c1720a Mon Sep 17 00:00:00 2001 From: Matt Connew Date: Thu, 5 Aug 2021 19:22:43 -0700 Subject: [PATCH 1/2] Implemented Mtom --- .../Diagnostics/DiagnosticTraceBase.cs | 2 +- .../Internals/System/Text/BinHexEncoding.cs | 172 + .../src/Internals/System/Xml/XmlConverter.cs | 25 + .../System/Xml/XmlExceptionHelper.cs | 60 + .../src/Internals/System/Xml/XmlMtomReader.cs | 3215 +++++++++++++++++ .../src/Internals/System/Xml/XmlMtomWriter.cs | 1553 ++++++++ .../src/Internals/WcfEventSource.cs | 39 + .../src/Resources/Strings.resx | 171 +- .../src/Resources/xlf/Strings.cs.xlf | 275 ++ .../src/Resources/xlf/Strings.de.xlf | 275 ++ .../src/Resources/xlf/Strings.es.xlf | 275 ++ .../src/Resources/xlf/Strings.fr.xlf | 275 ++ .../src/Resources/xlf/Strings.it.xlf | 275 ++ .../src/Resources/xlf/Strings.ja.xlf | 275 ++ .../src/Resources/xlf/Strings.ko.xlf | 275 ++ .../src/Resources/xlf/Strings.pl.xlf | 275 ++ .../src/Resources/xlf/Strings.pt-BR.xlf | 275 ++ .../src/Resources/xlf/Strings.ru.xlf | 275 ++ .../src/Resources/xlf/Strings.tr.xlf | 275 ++ .../src/Resources/xlf/Strings.zh-Hans.xlf | 275 ++ .../src/Resources/xlf/Strings.zh-Hant.xlf | 275 ++ .../src/System.Private.ServiceModel.csproj | 17 +- .../System/ServiceModel/BasicHttpBinding.cs | 10 +- .../System/ServiceModel/BasicHttpsBinding.cs | 12 +- .../ServiceModel/Channels/MessageEncoder.cs | 12 + .../Channels/MtomMessageEncoder.cs | 687 ++++ .../MtomMessageEncodingBindingElement.cs | 230 ++ .../Channels/TextMessageEncoder.cs | 1 - .../Channels/TransportDefaults.cs | 32 +- .../Dispatcher/StreamFormatter.cs | 9 +- .../System/ServiceModel/HttpBindingBase.cs | 9 + .../src/System/ServiceModel/NetHttpBinding.cs | 15 +- .../System/ServiceModel/NetHttpsBinding.cs | 15 +- .../System/ServiceModel/WSHttpBindingBase.cs | 20 +- .../System/ServiceModel/WSMessageEncoding.cs | 11 + .../tests/Common/Scenarios/Endpoints.cs | 106 +- .../Http/BasicHttpBindingTests.4.0.0.cs | 65 +- .../Binding/Http/NetHttpBindingTests.4.0.0.cs | 13 +- .../Http/NetHttpsBindingTests.4.1.0.cs | 15 +- .../Binding/Http/OperationContextTests.cs | 2 +- .../Binding/Http/WSHttpBindingTests.cs | 47 + .../RequestReplyChannelShapeTests.4.0.0.cs | 4 +- .../RequestReplyChannelShapeTests.4.1.0.cs | 2 +- .../ClientBase/ClientBaseTests.4.0.0.cs | 2 +- .../ClientBase/ClientBaseTests.4.1.0.cs | 6 +- .../ClientBase/DuplexClientBaseTests.4.1.0.cs | 2 +- .../ClientBase/MessageInspectorTests.4.4.0.cs | 4 +- .../ExpectedExceptionTests.4.0.0.cs | 12 +- .../ExpectedExceptionTests.4.1.0.cs | 8 +- .../Fault/FaultExceptionTests.4.0.0.cs | 16 +- .../Message/MessageContractCommon.4.1.0.cs | 2 +- .../Contract/Message/MessageTests.4.0.0.cs | 4 +- .../Service/ServiceContractTests.4.0.0.cs | 8 +- .../Service/ServiceContractTests.4.1.0.cs | 20 +- .../Service/ServiceKnownTypeTests.4.0.0.cs | 2 +- .../XmlSerializerFormatTest.4.0.0.cs | 2 +- .../XmlSerializerFormatTest.4.1.0.cs | 6 +- .../Encoders/TextEncodingTests.4.1.0.cs | 4 +- .../WebSockets/WebSocketTests.4.1.0.cs | 856 ++--- .../Https/HttpsTests.4.1.0.cs | 56 +- .../testhosts/BasicHttpTestServiceHost.cs | 13 +- .../testhosts/BasicHttpsTestServiceHost.cs | 13 +- .../testhosts/NetHttpTestServiceHost.cs | 17 +- .../testhosts/NetHttpsTestServiceHost.cs | 17 +- .../testhosts/WSHttpBindingTestServiceHost.cs | 33 + .../testhosts/WebSocketTestServiceHosts.cs | 336 +- .../ref/System.ServiceModel.Http.cs | 14 +- 67 files changed, 10515 insertions(+), 1084 deletions(-) create mode 100644 src/System.Private.ServiceModel/src/Internals/System/Text/BinHexEncoding.cs create mode 100644 src/System.Private.ServiceModel/src/Internals/System/Xml/XmlConverter.cs create mode 100644 src/System.Private.ServiceModel/src/Internals/System/Xml/XmlExceptionHelper.cs create mode 100644 src/System.Private.ServiceModel/src/Internals/System/Xml/XmlMtomReader.cs create mode 100644 src/System.Private.ServiceModel/src/Internals/System/Xml/XmlMtomWriter.cs create mode 100644 src/System.Private.ServiceModel/src/System/ServiceModel/Channels/MtomMessageEncoder.cs create mode 100644 src/System.Private.ServiceModel/src/System/ServiceModel/Channels/MtomMessageEncodingBindingElement.cs create mode 100644 src/System.Private.ServiceModel/tests/Scenarios/Binding/Http/WSHttpBindingTests.cs create mode 100644 src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/WSHttpBindingTestServiceHost.cs diff --git a/src/System.Private.ServiceModel/src/Internals/System/Runtime/Diagnostics/DiagnosticTraceBase.cs b/src/System.Private.ServiceModel/src/Internals/System/Runtime/Diagnostics/DiagnosticTraceBase.cs index 440f003599c..a0c9c9b2f12 100644 --- a/src/System.Private.ServiceModel/src/Internals/System/Runtime/Diagnostics/DiagnosticTraceBase.cs +++ b/src/System.Private.ServiceModel/src/Internals/System/Runtime/Diagnostics/DiagnosticTraceBase.cs @@ -85,7 +85,7 @@ internal static string CreateDefaultSourceString(object source) throw new ArgumentNullException("source"); } - return String.Format(CultureInfo.CurrentCulture, "{0}/{1}", source.GetType().ToString(), source.GetHashCode()); + return string.Format(CultureInfo.CurrentCulture, "{0}/{1}", source.GetType().ToString(), source.GetHashCode()); } protected static void AddExceptionToTraceString(XmlWriter xml, Exception exception) diff --git a/src/System.Private.ServiceModel/src/Internals/System/Text/BinHexEncoding.cs b/src/System.Private.ServiceModel/src/Internals/System/Text/BinHexEncoding.cs new file mode 100644 index 00000000000..d22a8352138 --- /dev/null +++ b/src/System.Private.ServiceModel/src/Internals/System/Text/BinHexEncoding.cs @@ -0,0 +1,172 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Globalization; +using System.Runtime; +using System.ServiceModel; + +namespace System.Text +{ + internal class BinHexEncoding : Encoding + { + private static byte[] s_char2val = new byte[128] + { + /* 0-15 */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + /* 16-31 */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + /* 32-47 */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + /* 48-63 */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + /* 64-79 */ 0xFF, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + /* 80-95 */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + /* 96-111 */ 0xFF, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + /* 112-127 */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + }; + private static string s_val2char = "0123456789ABCDEF"; + +#if DEBUG + static BinHexEncoding() + { + for (char ch = '0'; ch <= '9'; ch++) + { + Fx.Assert(s_char2val[ch] == ch - '0', ""); + } + + for (char ch = 'A'; ch <= 'F'; ch++) + { + Fx.Assert(s_char2val[ch] == ch - 'A' + 10, ""); + } + + for (char ch = 'a'; ch <= 'f'; ch++) + { + Fx.Assert(s_char2val[ch] == ch - 'a' + 10, ""); + } + } +#endif + + public override int GetMaxByteCount(int charCount) + { + if (charCount < 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charCount), SR.ValueMustBeNonNegative)); + if ((charCount % 2) != 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.Format(SR.XmlInvalidBinHexLength, charCount.ToString(NumberFormatInfo.CurrentInfo)))); + return charCount / 2; + } + + public override int GetByteCount(char[] chars, int index, int count) + { + return GetMaxByteCount(count); + } + + public override unsafe int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) + { + if (chars == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("chars")); + if (charIndex < 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charIndex), SR.ValueMustBeNonNegative)); + if (charIndex > chars.Length) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charIndex), SR.Format(SR.OffsetExceedsBufferSize, chars.Length))); + if (charCount < 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charCount), SR.ValueMustBeNonNegative)); + if (charCount > chars.Length - charIndex) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charCount), SR.Format(SR.SizeExceedsRemainingBufferSpace, chars.Length - charIndex))); + if (bytes == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(bytes))); + if (byteIndex < 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteIndex), SR.ValueMustBeNonNegative)); + if (byteIndex > bytes.Length) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteIndex), SR.Format(SR.OffsetExceedsBufferSize, bytes.Length))); + int byteCount = GetByteCount(chars, charIndex, charCount); + if (byteCount < 0 || byteCount > bytes.Length - byteIndex) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.XmlArrayTooSmall, nameof(bytes))); + if (charCount > 0) + { + fixed (byte* _char2val = s_char2val) + { + fixed (byte* _bytes = &bytes[byteIndex]) + { + fixed (char* _chars = &chars[charIndex]) + { + char* pch = _chars; + char* pchMax = _chars + charCount; + byte* pb = _bytes; + while (pch < pchMax) + { + Fx.Assert(pch + 2 <= pchMax, ""); + char pch0 = pch[0]; + char pch1 = pch[1]; + if ((pch0 | pch1) >= 128) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.Format(SR.XmlInvalidBinHexSequence, new string(pch, 0, 2), charIndex + (int)(pch - _chars)))); + byte d1 = _char2val[pch0]; + byte d2 = _char2val[pch1]; + if ((d1 | d2) == 0xFF) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.Format(SR.XmlInvalidBinHexSequence, new string(pch, 0, 2), charIndex + (int)(pch - _chars)))); + pb[0] = (byte)((d1 << 4) + d2); + pch += 2; + pb++; + } + } + } + } + } + return byteCount; + } + + public override int GetMaxCharCount(int byteCount) + { + if (byteCount < 0 || byteCount > int.MaxValue / 2) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteCount), SR.Format(SR.ValueMustBeInRange, 0, int.MaxValue / 2))); + return byteCount * 2; + } + + public override int GetCharCount(byte[] bytes, int index, int count) + { + return GetMaxCharCount(count); + } + + public override unsafe int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) + { + if (bytes == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("bytes")); + if (byteIndex < 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteIndex), SR.ValueMustBeNonNegative)); + if (byteIndex > bytes.Length) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteIndex), SR.Format(SR.OffsetExceedsBufferSize, bytes.Length))); + if (byteCount < 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteCount), SR.ValueMustBeNonNegative)); + if (byteCount > bytes.Length - byteIndex) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteCount), SR.Format(SR.SizeExceedsRemainingBufferSpace, bytes.Length - byteIndex))); + int charCount = GetCharCount(bytes, byteIndex, byteCount); + if (chars == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("chars")); + if (charIndex < 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charIndex), SR.ValueMustBeNonNegative)); + if (charIndex > chars.Length) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charIndex), SR.Format(SR.OffsetExceedsBufferSize, chars.Length))); + if (charCount < 0 || charCount > chars.Length - charIndex) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.XmlArrayTooSmall, "chars")); + if (byteCount > 0) + { + fixed (char* _val2char = s_val2char) + { + fixed (byte* _bytes = &bytes[byteIndex]) + { + fixed (char* _chars = &chars[charIndex]) + { + char* pch = _chars; + byte* pb = _bytes; + byte* pbMax = _bytes + byteCount; + while (pb < pbMax) + { + pch[0] = _val2char[pb[0] >> 4]; + pch[1] = _val2char[pb[0] & 0x0F]; + pb++; + pch += 2; + } + } + } + } + } + return charCount; + } + } +} diff --git a/src/System.Private.ServiceModel/src/Internals/System/Xml/XmlConverter.cs b/src/System.Private.ServiceModel/src/Internals/System/Xml/XmlConverter.cs new file mode 100644 index 00000000000..de5470834bb --- /dev/null +++ b/src/System.Private.ServiceModel/src/Internals/System/Xml/XmlConverter.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Xml +{ + internal static class XmlConverter + { + public static bool IsWhitespace(char ch) + { + return (ch <= ' ' && (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n')); + } + + public static bool IsWhitespace(string s) + { + for (int i = 0; i < s.Length; i++) + { + if (!IsWhitespace(s[i])) + return false; + } + + return true; + } + } +} diff --git a/src/System.Private.ServiceModel/src/Internals/System/Xml/XmlExceptionHelper.cs b/src/System.Private.ServiceModel/src/Internals/System/Xml/XmlExceptionHelper.cs new file mode 100644 index 00000000000..8b229abfff5 --- /dev/null +++ b/src/System.Private.ServiceModel/src/Internals/System/Xml/XmlExceptionHelper.cs @@ -0,0 +1,60 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Globalization; +using System.ServiceModel; + +namespace System.Xml +{ + internal static class XmlExceptionHelper + { + static void ThrowXmlException(XmlDictionaryReader reader, string res) + { + ThrowXmlException(reader, res, null); + } + + static void ThrowXmlException(XmlDictionaryReader reader, string res, string arg1) + { + ThrowXmlException(reader, res, arg1, null); + } + + static void ThrowXmlException(XmlDictionaryReader reader, string res, string arg1, string arg2) + { + ThrowXmlException(reader, res, arg1, arg2, null); + } + + static void ThrowXmlException(XmlDictionaryReader reader, string res, string arg1, string arg2, string arg3) + { + string s = SR.Format(res, arg1, arg2, arg3); + IXmlLineInfo lineInfo = reader as IXmlLineInfo; + if (lineInfo != null && lineInfo.HasLineInfo()) + { + s += " " + SR.Format(SR.XmlLineInfo, lineInfo.LineNumber, lineInfo.LinePosition); + } + + //if (TD.ReaderQuotaExceededIsEnabled()) + //{ + // TD.ReaderQuotaExceeded(s); + //} + + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(s)); + } + + static public void ThrowXmlException(XmlDictionaryReader reader, XmlException exception) + { + string s = exception.Message; + IXmlLineInfo lineInfo = reader as IXmlLineInfo; + if (lineInfo != null && lineInfo.HasLineInfo()) + { + s += " " + SR.Format(SR.XmlLineInfo, lineInfo.LineNumber, lineInfo.LinePosition); + } + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(s)); + } + + static public void ThrowMaxStringContentLengthExceeded(XmlDictionaryReader reader, int maxStringContentLength) + { + ThrowXmlException(reader, SR.XmlMaxStringContentLengthExceeded, maxStringContentLength.ToString(NumberFormatInfo.CurrentInfo)); + } + } +} diff --git a/src/System.Private.ServiceModel/src/Internals/System/Xml/XmlMtomReader.cs b/src/System.Private.ServiceModel/src/Internals/System/Xml/XmlMtomReader.cs new file mode 100644 index 00000000000..7fc53f732c1 --- /dev/null +++ b/src/System.Private.ServiceModel/src/Internals/System/Xml/XmlMtomReader.cs @@ -0,0 +1,3215 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Runtime; +using System.Runtime.Serialization; +using System.Text; +using System.Security; +using System.Security.Permissions; +using System.ServiceModel; + +namespace System.Xml +{ + internal interface IXmlMtomReaderInitializer + { + void SetInput(byte[] buffer, int offset, int count, Encoding[] encodings, string contentType, XmlDictionaryReaderQuotas quotas, int maxBufferSize, OnXmlDictionaryReaderClose onClose); + void SetInput(Stream stream, Encoding[] encodings, string contentType, XmlDictionaryReaderQuotas quotas, int maxBufferSize, OnXmlDictionaryReaderClose onClose); + } + + internal class XmlMtomReader : XmlDictionaryReader, IXmlLineInfo, IXmlMtomReaderInitializer + { + public static XmlDictionaryReader Create(Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas) + { + if (encoding == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(encoding)); + + return Create(stream, new Encoding[1] { encoding }, quotas); + } + + public static XmlDictionaryReader Create(Stream stream, Encoding[] encodings, XmlDictionaryReaderQuotas quotas) + { + return Create(stream, encodings, null, quotas); + } + + public static XmlDictionaryReader Create(Stream stream, Encoding[] encodings, string contentType, XmlDictionaryReaderQuotas quotas) + { + return Create(stream, encodings, contentType, quotas, int.MaxValue, null); + } + + public static XmlDictionaryReader Create(Stream stream, Encoding[] encodings, string contentType, + XmlDictionaryReaderQuotas quotas, int maxBufferSize, OnXmlDictionaryReaderClose onClose) + { + XmlMtomReader reader = new XmlMtomReader(); + reader.SetInput(stream, encodings, contentType, quotas, maxBufferSize, onClose); + return reader; + } + + public static XmlDictionaryReader Create(byte[] buffer, int offset, int count, Encoding encoding, XmlDictionaryReaderQuotas quotas) + { + if (encoding == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(encoding)); + + return Create(buffer, offset, count, new Encoding[1] { encoding }, quotas); + } + + public static XmlDictionaryReader Create(byte[] buffer, int offset, int count, Encoding[] encodings, XmlDictionaryReaderQuotas quotas) + { + return Create(buffer, offset, count, encodings, null, quotas); + } + + public static XmlDictionaryReader Create(byte[] buffer, int offset, int count, Encoding[] encodings, string contentType, XmlDictionaryReaderQuotas quotas) + { + return Create(buffer, offset, count, encodings, contentType, quotas, int.MaxValue, null); + } + + public static XmlDictionaryReader Create(byte[] buffer, int offset, int count, Encoding[] encodings, string contentType, + XmlDictionaryReaderQuotas quotas, int maxBufferSize, OnXmlDictionaryReaderClose onClose) + { + XmlMtomReader reader = new XmlMtomReader(); + reader.SetInput(buffer, offset, count, encodings, contentType, quotas, maxBufferSize, onClose); + return reader; + } + + private Encoding[] _encodings; + private XmlDictionaryReader _xmlReader; + private XmlDictionaryReader _infosetReader; + private MimeReader _mimeReader; + private Dictionary _mimeParts; + private OnXmlDictionaryReaderClose _onClose; + private bool _readingBinaryElement; + private int _maxBufferSize; + private int _bufferRemaining; + private MimePart _part; + + public XmlMtomReader() + { + } + + internal static void DecrementBufferQuota(int maxBuffer, ref int remaining, int size) + { + if (remaining - size <= 0) + { + remaining = 0; + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MtomBufferQuotaExceeded, maxBuffer))); + } + else + { + remaining -= size; + } + } + + private void SetReadEncodings(Encoding[] encodings) + { + if (encodings == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(encodings)); + + for (int i = 0; i < encodings.Length; i++) + { + if (encodings[i] == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(string.Format(CultureInfo.InvariantCulture, "encodings[{0}]", i)); + } + + _encodings = new Encoding[encodings.Length]; + encodings.CopyTo(_encodings, 0); + } + + private void CheckContentType(string contentType) + { + if (contentType != null && contentType.Length == 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.MtomContentTypeInvalid, nameof(contentType))); + } + + public void SetInput(byte[] buffer, int offset, int count, Encoding[] encodings, string contentType, XmlDictionaryReaderQuotas quotas, int maxBufferSize, OnXmlDictionaryReaderClose onClose) + { + SetInput(new MemoryStream(buffer, offset, count), encodings, contentType, quotas, maxBufferSize, onClose); + } + + public void SetInput(Stream stream, Encoding[] encodings, string contentType, XmlDictionaryReaderQuotas quotas, int maxBufferSize, OnXmlDictionaryReaderClose onClose) + { + SetReadEncodings(encodings); + CheckContentType(contentType); + Initialize(stream, contentType, quotas, maxBufferSize); + _onClose = onClose; + } + + private void Initialize(Stream stream, string contentType, XmlDictionaryReaderQuotas quotas, int maxBufferSize) + { + if (stream == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(stream)); + + _maxBufferSize = maxBufferSize; + _bufferRemaining = maxBufferSize; + + string boundary, start, startInfo; + + if (contentType == null) + { + MimeMessageReader messageReader = new MimeMessageReader(stream); + MimeHeaders messageHeaders = messageReader.ReadHeaders(_maxBufferSize, ref _bufferRemaining); + ReadMessageMimeVersionHeader(messageHeaders.MimeVersion); + ReadMessageContentTypeHeader(messageHeaders.ContentType, out boundary, out start, out startInfo); + stream = messageReader.GetContentStream(); + if (stream == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.MtomMessageInvalidContent)); + } + else + { + ReadMessageContentTypeHeader(new ContentTypeHeader(contentType), out boundary, out start, out startInfo); + } + + _mimeReader = new MimeReader(stream, boundary); + _mimeParts = null; + _readingBinaryElement = false; + + MimePart infosetPart = (start == null) ? ReadRootMimePart() : ReadMimePart(GetStartUri(start)); + byte[] infosetBytes = infosetPart.GetBuffer(_maxBufferSize, ref _bufferRemaining); + int infosetByteCount = (int)infosetPart.Length; + + Encoding encoding = ReadRootContentTypeHeader(infosetPart.Headers.ContentType, _encodings, startInfo); + CheckContentTransferEncodingOnRoot(infosetPart.Headers.ContentTransferEncoding); + + IXmlTextReaderInitializer initializer = _xmlReader as IXmlTextReaderInitializer; + + if (initializer != null) + initializer.SetInput(infosetBytes, 0, infosetByteCount, encoding, quotas, null); + else + _xmlReader = XmlDictionaryReader.CreateTextReader(infosetBytes, 0, infosetByteCount, encoding, quotas, null); + } + + public override XmlDictionaryReaderQuotas Quotas + { + get + { + return _xmlReader.Quotas; + } + } + + private void ReadMessageMimeVersionHeader(MimeVersionHeader header) + { + if (header != null && header.Version != MimeVersionHeader.Default.Version) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MtomMessageInvalidMimeVersion, header.Version, MimeVersionHeader.Default.Version))); + } + + private void ReadMessageContentTypeHeader(ContentTypeHeader header, out string boundary, out string start, out string startInfo) + { + if (header == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.MtomMessageContentTypeNotFound)); + + if (string.Compare(MtomGlobals.MediaType, header.MediaType, StringComparison.OrdinalIgnoreCase) != 0 + || string.Compare(MtomGlobals.MediaSubtype, header.MediaSubtype, StringComparison.OrdinalIgnoreCase) != 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MtomMessageNotMultipart, MtomGlobals.MediaType, MtomGlobals.MediaSubtype))); + + string type; + if (!header.Parameters.TryGetValue(MtomGlobals.TypeParam, out type) || MtomGlobals.XopType != type) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MtomMessageNotApplicationXopXml, MtomGlobals.XopType))); + + if (!header.Parameters.TryGetValue(MtomGlobals.BoundaryParam, out boundary)) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MtomMessageRequiredParamNotSpecified, MtomGlobals.BoundaryParam))); + if (!MailBnfHelper.IsValidMimeBoundary(boundary)) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MtomBoundaryInvalid, boundary))); + + if (!header.Parameters.TryGetValue(MtomGlobals.StartParam, out start)) + start = null; + + if (!header.Parameters.TryGetValue(MtomGlobals.StartInfoParam, out startInfo)) + startInfo = null; + } + + private Encoding ReadRootContentTypeHeader(ContentTypeHeader header, Encoding[] expectedEncodings, string expectedType) + { + if (header == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.MtomRootContentTypeNotFound)); + + if (string.Compare(MtomGlobals.XopMediaType, header.MediaType, StringComparison.OrdinalIgnoreCase) != 0 + || string.Compare(MtomGlobals.XopMediaSubtype, header.MediaSubtype, StringComparison.OrdinalIgnoreCase) != 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MtomRootNotApplicationXopXml, MtomGlobals.XopMediaType, MtomGlobals.XopMediaSubtype))); + + string charset; + if (!header.Parameters.TryGetValue(MtomGlobals.CharsetParam, out charset) + || charset == null || charset.Length == 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MtomRootRequiredParamNotSpecified, MtomGlobals.CharsetParam))); + Encoding encoding = null; + for (int i = 0; i < _encodings.Length; i++) + { + if (string.Compare(charset, expectedEncodings[i].WebName, StringComparison.OrdinalIgnoreCase) == 0) + { + encoding = expectedEncodings[i]; + break; + } + } + if (encoding == null) + { + // Check for alternate names + if (string.Compare(charset, "utf-16LE", StringComparison.OrdinalIgnoreCase) == 0) + { + for (int i = 0; i < _encodings.Length; i++) + { + if (string.Compare(expectedEncodings[i].WebName, Encoding.Unicode.WebName, StringComparison.OrdinalIgnoreCase) == 0) + { + encoding = expectedEncodings[i]; + break; + } + } + } + else if (string.Compare(charset, "utf-16BE", StringComparison.OrdinalIgnoreCase) == 0) + { + for (int i = 0; i < _encodings.Length; i++) + { + if (string.Compare(expectedEncodings[i].WebName, Encoding.BigEndianUnicode.WebName, StringComparison.OrdinalIgnoreCase) == 0) + { + encoding = expectedEncodings[i]; + break; + } + } + } + + if (encoding == null) + { + StringBuilder expectedCharSetStr = new StringBuilder(); + for (int i = 0; i < _encodings.Length; i++) + { + if (expectedCharSetStr.Length != 0) + expectedCharSetStr.Append(" | "); + expectedCharSetStr.Append(_encodings[i].WebName); + } + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MtomRootUnexpectedCharset, charset, expectedCharSetStr.ToString()))); + } + } + + if (expectedType != null) + { + string rootType; + if (!header.Parameters.TryGetValue(MtomGlobals.TypeParam, out rootType) + || rootType == null || rootType.Length == 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MtomRootRequiredParamNotSpecified, MtomGlobals.TypeParam))); + if (rootType != expectedType) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MtomRootUnexpectedType, rootType, expectedType))); + } + + return encoding; + } + + // 7bit is default encoding in the absence of content-transfer-encoding header + private void CheckContentTransferEncodingOnRoot(ContentTransferEncodingHeader header) + { + if (header != null && header.ContentTransferEncoding == ContentTransferEncoding.Other) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MtomContentTransferEncodingNotSupported, + header.Value, + ContentTransferEncodingHeader.SevenBit.ContentTransferEncodingValue, + ContentTransferEncodingHeader.EightBit.ContentTransferEncodingValue, + ContentTransferEncodingHeader.Binary.ContentTransferEncodingValue))); + } + + private void CheckContentTransferEncodingOnBinaryPart(ContentTransferEncodingHeader header) + { + if (header == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MtomContentTransferEncodingNotPresent, + ContentTransferEncodingHeader.Binary.ContentTransferEncodingValue))); + else if (header.ContentTransferEncoding != ContentTransferEncoding.Binary) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MtomInvalidTransferEncodingForMimePart, + header.Value, ContentTransferEncodingHeader.Binary.ContentTransferEncodingValue))); + } + + private string GetStartUri(string startUri) + { + if (startUri.StartsWith("<", StringComparison.Ordinal)) + { + if (startUri.EndsWith(">", StringComparison.Ordinal)) + return startUri; + else + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MtomInvalidStartUri, startUri))); + } + else + return string.Format(CultureInfo.InvariantCulture, "<{0}>", startUri); + } + + public override bool Read() + { + bool retVal = _xmlReader.Read(); + + if (_xmlReader.NodeType == XmlNodeType.Element) + { + XopIncludeReader binaryDataReader = null; + if (_xmlReader.IsStartElement(MtomGlobals.XopIncludeLocalName, MtomGlobals.XopIncludeNamespace)) + { + string uri = null; + while (_xmlReader.MoveToNextAttribute()) + { + if (_xmlReader.LocalName == MtomGlobals.XopIncludeHrefLocalName && _xmlReader.NamespaceURI == MtomGlobals.XopIncludeHrefNamespace) + uri = _xmlReader.Value; + else if (_xmlReader.NamespaceURI == MtomGlobals.XopIncludeNamespace) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MtomXopIncludeInvalidXopAttributes, _xmlReader.LocalName, MtomGlobals.XopIncludeNamespace))); + } + if (uri == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MtomXopIncludeHrefNotSpecified, MtomGlobals.XopIncludeHrefLocalName))); + + MimePart mimePart = ReadMimePart(uri); + + CheckContentTransferEncodingOnBinaryPart(mimePart.Headers.ContentTransferEncoding); + + _part = mimePart; + binaryDataReader = new XopIncludeReader(mimePart, _xmlReader); + binaryDataReader.Read(); + + _xmlReader.MoveToElement(); + if (_xmlReader.IsEmptyElement) + { + _xmlReader.Read(); + } + else + { + int xopDepth = _xmlReader.Depth; + _xmlReader.ReadStartElement(); + + while (_xmlReader.Depth > xopDepth) + { + if (_xmlReader.IsStartElement() && _xmlReader.NamespaceURI == MtomGlobals.XopIncludeNamespace) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MtomXopIncludeInvalidXopElement, _xmlReader.LocalName, MtomGlobals.XopIncludeNamespace))); + + _xmlReader.Skip(); + } + + _xmlReader.ReadEndElement(); + } + } + + if (binaryDataReader != null) + { + _xmlReader.MoveToContent(); + _infosetReader = _xmlReader; + _xmlReader = binaryDataReader; + binaryDataReader = null; + } + } + + if (_xmlReader.ReadState == ReadState.EndOfFile && _infosetReader != null) + { + // Read past the containing EndElement if necessary + if (!retVal) + retVal = _infosetReader.Read(); + + _part.Release(_maxBufferSize, ref _bufferRemaining); + _xmlReader = _infosetReader; + _infosetReader = null; + } + + return retVal; + } + + private MimePart ReadMimePart(string uri) + { + MimePart part = null; + + if (uri == null || uri.Length == 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.MtomInvalidEmptyURI)); + + string contentID = null; + if (uri.StartsWith(MimeGlobals.ContentIDScheme, StringComparison.Ordinal)) + contentID = string.Format(CultureInfo.InvariantCulture, "<{0}>", Uri.UnescapeDataString(uri.Substring(MimeGlobals.ContentIDScheme.Length))); + else if (uri.StartsWith("<", StringComparison.Ordinal)) + contentID = uri; + + if (contentID == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MtomInvalidCIDUri, uri))); + + if (_mimeParts != null && _mimeParts.TryGetValue(contentID, out part)) + { + if (part.ReferencedFromInfoset) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MtomMimePartReferencedMoreThanOnce, contentID))); + } + else + { + // TODO: Fix this to be a configurable setting on MtomMessageEncodingBindingElement + int maxMimeParts = 1000; // AppSettings.MaxMimeParts; + while (part == null && _mimeReader.ReadNextPart()) + { + MimeHeaders headers = _mimeReader.ReadHeaders(_maxBufferSize, ref _bufferRemaining); + Stream contentStream = _mimeReader.GetContentStream(); + if (contentStream == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.MtomMessageInvalidContentInMimePart)); + + ContentIDHeader contentIDHeader = (headers == null) ? null : headers.ContentID; + if (contentIDHeader == null || contentIDHeader.Value == null) + { + // Skip content if Content-ID header is not present + int size = 256; + byte[] bytes = new byte[size]; + + int read = 0; + do + { + read = contentStream.Read(bytes, 0, size); + } + while (read > 0); + continue; + } + + string currentContentID = headers.ContentID.Value; + MimePart currentPart = new MimePart(contentStream, headers); + if (_mimeParts == null) + _mimeParts = new Dictionary(); + + _mimeParts.Add(currentContentID, currentPart); + + if (_mimeParts.Count > maxMimeParts) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MaxMimePartsExceeded, maxMimeParts, "MtomMessageEncoderBindingElement"))); + + if (currentContentID.Equals(contentID)) + part = currentPart; + else + currentPart.GetBuffer(_maxBufferSize, ref _bufferRemaining); + } + + if (part == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MtomPartNotFound, uri))); + } + + part.ReferencedFromInfoset = true; + return part; + } + + private MimePart ReadRootMimePart() + { + MimePart part = null; + + if (!_mimeReader.ReadNextPart()) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.MtomRootPartNotFound)); + + MimeHeaders headers = _mimeReader.ReadHeaders(_maxBufferSize, ref _bufferRemaining); + Stream contentStream = _mimeReader.GetContentStream(); + if (contentStream == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.MtomMessageInvalidContentInMimePart)); + part = new MimePart(contentStream, headers); + + return part; + } + + private void AdvanceToContentOnElement() + { + if (NodeType != XmlNodeType.Attribute) + { + MoveToContent(); + } + } + + public override int AttributeCount + { + get + { + return _xmlReader.AttributeCount; + } + } + + public override string BaseURI + { + get + { + return _xmlReader.BaseURI; + } + } + + public override bool CanReadBinaryContent + { + get + { + return _xmlReader.CanReadBinaryContent; + } + } + + public override bool CanReadValueChunk + { + get + { + return _xmlReader.CanReadValueChunk; + } + } + + public override bool CanResolveEntity + { + get + { + return _xmlReader.CanResolveEntity; + } + } + + public override void Close() + { + _xmlReader.Close(); + _mimeReader.Close(); + OnXmlDictionaryReaderClose onClose = _onClose; + _onClose = null; + if (onClose != null) + { + try + { + onClose(this); + } + catch (Exception e) + { + if (Fx.IsFatal(e)) + throw; + + throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e); + } + } + } + + public override int Depth + { + get + { + return _xmlReader.Depth; + } + } + + public override bool EOF + { + get + { + return _xmlReader.EOF; + } + } + + public override string GetAttribute(int index) + { + return _xmlReader.GetAttribute(index); + } + + public override string GetAttribute(string name) + { + return _xmlReader.GetAttribute(name); + } + + public override string GetAttribute(string name, string ns) + { + return _xmlReader.GetAttribute(name, ns); + } + + public override string GetAttribute(XmlDictionaryString localName, XmlDictionaryString ns) + { + return _xmlReader.GetAttribute(localName, ns); + } +#if NO + public override ArraySegment GetSubset(bool advance) + { + return xmlReader.GetSubset(advance); + } +#endif + public override bool HasAttributes + { + get + { + return _xmlReader.HasAttributes; + } + } + + public override bool HasValue + { + get + { + return _xmlReader.HasValue; + } + } + + public override bool IsDefault + { + get + { + return _xmlReader.IsDefault; + } + } + + public override bool IsEmptyElement + { + get + { + return _xmlReader.IsEmptyElement; + } + } + + public override bool IsLocalName(string localName) + { + return _xmlReader.IsLocalName(localName); + } + + public override bool IsLocalName(XmlDictionaryString localName) + { + return _xmlReader.IsLocalName(localName); + } + + public override bool IsNamespaceUri(string ns) + { + return _xmlReader.IsNamespaceUri(ns); + } + + public override bool IsNamespaceUri(XmlDictionaryString ns) + { + return _xmlReader.IsNamespaceUri(ns); + } + + public override bool IsStartElement() + { + return _xmlReader.IsStartElement(); + } + + public override bool IsStartElement(string localName) + { + return _xmlReader.IsStartElement(localName); + } + + public override bool IsStartElement(string localName, string ns) + { + return _xmlReader.IsStartElement(localName, ns); + } + + public override bool IsStartElement(XmlDictionaryString localName, XmlDictionaryString ns) + { + return _xmlReader.IsStartElement(localName, ns); + } +#if NO + public override bool IsStartSubsetElement() + { + return xmlReader.IsStartSubsetElement(); + } +#endif + public override string LocalName + { + get + { + return _xmlReader.LocalName; + } + } + + public override string LookupNamespace(string ns) + { + return _xmlReader.LookupNamespace(ns); + } + + public override void MoveToAttribute(int index) + { + _xmlReader.MoveToAttribute(index); + } + + public override bool MoveToAttribute(string name) + { + return _xmlReader.MoveToAttribute(name); + } + + public override bool MoveToAttribute(string name, string ns) + { + return _xmlReader.MoveToAttribute(name, ns); + } + + public override bool MoveToElement() + { + return _xmlReader.MoveToElement(); + } + + public override bool MoveToFirstAttribute() + { + return _xmlReader.MoveToFirstAttribute(); + } + + public override bool MoveToNextAttribute() + { + return _xmlReader.MoveToNextAttribute(); + } + + public override string Name + { + get + { + return _xmlReader.Name; + } + } + + public override string NamespaceURI + { + get + { + return _xmlReader.NamespaceURI; + } + } + + public override XmlNameTable NameTable + { + get + { + return _xmlReader.NameTable; + } + } + + public override XmlNodeType NodeType + { + get + { + return _xmlReader.NodeType; + } + } + + public override string Prefix + { + get + { + return _xmlReader.Prefix; + } + } + + public override char QuoteChar + { + get + { + return _xmlReader.QuoteChar; + } + } + + public override bool ReadAttributeValue() + { + return _xmlReader.ReadAttributeValue(); + } + + public override object ReadContentAs(Type returnType, IXmlNamespaceResolver namespaceResolver) + { + AdvanceToContentOnElement(); + return _xmlReader.ReadContentAs(returnType, namespaceResolver); + } + + public override byte[] ReadContentAsBase64() + { + AdvanceToContentOnElement(); + return _xmlReader.ReadContentAsBase64(); + } + + public override int ReadValueAsBase64(byte[] buffer, int offset, int count) + { + AdvanceToContentOnElement(); + return _xmlReader.ReadValueAsBase64(buffer, offset, count); + } + + public override int ReadContentAsBase64(byte[] buffer, int offset, int count) + { + AdvanceToContentOnElement(); + return _xmlReader.ReadContentAsBase64(buffer, offset, count); + } + + public override int ReadElementContentAsBase64(byte[] buffer, int offset, int count) + { + if (!_readingBinaryElement) + { + if (IsEmptyElement) + { + Read(); + return 0; + } + + ReadStartElement(); + _readingBinaryElement = true; + } + + int i = ReadContentAsBase64(buffer, offset, count); + + if (i == 0) + { + ReadEndElement(); + _readingBinaryElement = false; + } + + return i; + } + + public override int ReadElementContentAsBinHex(byte[] buffer, int offset, int count) + { + if (!_readingBinaryElement) + { + if (IsEmptyElement) + { + Read(); + return 0; + } + + ReadStartElement(); + _readingBinaryElement = true; + } + + int i = ReadContentAsBinHex(buffer, offset, count); + + if (i == 0) + { + ReadEndElement(); + _readingBinaryElement = false; + } + + return i; + } + + public override int ReadContentAsBinHex(byte[] buffer, int offset, int count) + { + AdvanceToContentOnElement(); + return _xmlReader.ReadContentAsBinHex(buffer, offset, count); + } + + public override bool ReadContentAsBoolean() + { + AdvanceToContentOnElement(); + return _xmlReader.ReadContentAsBoolean(); + } + + public override int ReadContentAsChars(char[] chars, int index, int count) + { + AdvanceToContentOnElement(); + return _xmlReader.ReadContentAsChars(chars, index, count); + } + + public override DateTime ReadContentAsDateTime() + { + AdvanceToContentOnElement(); + return _xmlReader.ReadContentAsDateTime(); + } + + public override decimal ReadContentAsDecimal() + { + AdvanceToContentOnElement(); + return _xmlReader.ReadContentAsDecimal(); + } + + public override double ReadContentAsDouble() + { + AdvanceToContentOnElement(); + return _xmlReader.ReadContentAsDouble(); + } + + public override int ReadContentAsInt() + { + AdvanceToContentOnElement(); + return _xmlReader.ReadContentAsInt(); + } + + public override long ReadContentAsLong() + { + AdvanceToContentOnElement(); + return _xmlReader.ReadContentAsLong(); + } +#if NO + public override ICollection ReadContentAsList() + { + AdvanceToContentOnElement(); + return xmlReader.ReadContentAsList(); + } +#endif + public override object ReadContentAsObject() + { + AdvanceToContentOnElement(); + return _xmlReader.ReadContentAsObject(); + } + + public override float ReadContentAsFloat() + { + AdvanceToContentOnElement(); + return _xmlReader.ReadContentAsFloat(); + } + + public override string ReadContentAsString() + { + AdvanceToContentOnElement(); + return _xmlReader.ReadContentAsString(); + } + + public override string ReadInnerXml() + { + return _xmlReader.ReadInnerXml(); + } + + public override string ReadOuterXml() + { + return _xmlReader.ReadOuterXml(); + } + + public override ReadState ReadState + { + get + { + if (_xmlReader.ReadState != ReadState.Interactive && _infosetReader != null) + return _infosetReader.ReadState; + + return _xmlReader.ReadState; + } + } + + public override int ReadValueChunk(char[] buffer, int index, int count) + { + return _xmlReader.ReadValueChunk(buffer, index, count); + } + + public override void ResolveEntity() + { + _xmlReader.ResolveEntity(); + } + + public override XmlReaderSettings Settings + { + get + { + return _xmlReader.Settings; + } + } + + public override void Skip() + { + _xmlReader.Skip(); + } + + public override string this[int index] + { + get + { + return _xmlReader[index]; + } + } + + public override string this[string name] + { + get + { + return _xmlReader[name]; + } + } + + public override string this[string name, string ns] + { + get + { + return _xmlReader[name, ns]; + } + } + + public override string Value + { + get + { + return _xmlReader.Value; + } + } + + public override Type ValueType + { + get + { + return _xmlReader.ValueType; + } + } + + public override string XmlLang + { + get + { + return _xmlReader.XmlLang; + } + } + + public override XmlSpace XmlSpace + { + get + { + return _xmlReader.XmlSpace; + } + } + + public bool HasLineInfo() + { + if (_xmlReader.ReadState == ReadState.Closed) + return false; + + IXmlLineInfo lineInfo = _xmlReader as IXmlLineInfo; + if (lineInfo == null) + return false; + return lineInfo.HasLineInfo(); + } + + public int LineNumber + { + get + { + if (_xmlReader.ReadState == ReadState.Closed) + return 0; + + IXmlLineInfo lineInfo = _xmlReader as IXmlLineInfo; + if (lineInfo == null) + return 0; + return lineInfo.LineNumber; + } + } + + public int LinePosition + { + get + { + if (_xmlReader.ReadState == ReadState.Closed) + return 0; + + IXmlLineInfo lineInfo = _xmlReader as IXmlLineInfo; + if (lineInfo == null) + return 0; + return lineInfo.LinePosition; + } + } + + internal class MimePart + { + private Stream stream; + private MimeHeaders headers; + private byte[] buffer; + private bool isReferencedFromInfoset; + + internal MimePart(Stream stream, MimeHeaders headers) + { + this.stream = stream; + this.headers = headers; + } + + internal Stream Stream + { + get { return stream; } + } + + internal MimeHeaders Headers + { + get { return headers; } + } + + internal bool ReferencedFromInfoset + { + get { return isReferencedFromInfoset; } + set { isReferencedFromInfoset = value; } + } + + internal long Length + { + get { return stream.CanSeek ? stream.Length : 0; } + } + + internal byte[] GetBuffer(int maxBuffer, ref int remaining) + { + if (buffer == null) + { + MemoryStream bufferedStream = stream.CanSeek ? new MemoryStream((int)stream.Length) : new MemoryStream(); + int size = 256; + byte[] bytes = new byte[size]; + + int read = 0; + + do + { + read = stream.Read(bytes, 0, size); + XmlMtomReader.DecrementBufferQuota(maxBuffer, ref remaining, read); + if (read > 0) + bufferedStream.Write(bytes, 0, read); + } + while (read > 0); + + bufferedStream.Seek(0, SeekOrigin.Begin); + buffer = bufferedStream.GetBuffer(); + stream = bufferedStream; + } + return buffer; + } + + internal void Release(int maxBuffer, ref int remaining) + { + remaining += (int)Length; + headers.Release(ref remaining); + } + } + + internal class XopIncludeReader : XmlDictionaryReader, IXmlLineInfo + { + private int _chunkSize = 4096; // Just a default. Serves as a max chunk size. + private int _bytesRemaining; + private MimePart _part; + private ReadState _readState; + private XmlDictionaryReader _parentReader; + private string _stringValue; + private int _stringOffset; + private XmlNodeType _nodeType; + private MemoryStream _binHexStream; + private byte[] _valueBuffer; + private int _valueOffset; + private int _valueCount; + private bool _finishedStream; + + public XopIncludeReader(MimePart part, XmlDictionaryReader reader) + { + if (part == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(part)); + if (reader == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(reader)); + + _part = part; + _parentReader = reader; + _readState = ReadState.Initial; + _nodeType = XmlNodeType.None; + _chunkSize = Math.Min(reader.Quotas.MaxBytesPerRead, _chunkSize); + _bytesRemaining = _chunkSize; + _finishedStream = false; + } + + public override XmlDictionaryReaderQuotas Quotas + { + get + { + return _parentReader.Quotas; + } + } + + public override XmlNodeType NodeType + { + get + { + return (_readState == ReadState.Interactive) ? _nodeType : _parentReader.NodeType; + } + } + + public override bool Read() + { + bool retVal = true; + switch (_readState) + { + case ReadState.Initial: + _readState = ReadState.Interactive; + _nodeType = XmlNodeType.Text; + break; + case ReadState.Interactive: + if (_finishedStream || (_bytesRemaining == _chunkSize && _stringValue == null)) + { + _readState = ReadState.EndOfFile; + _nodeType = XmlNodeType.EndElement; + } + else + { + _bytesRemaining = _chunkSize; + } + break; + case ReadState.EndOfFile: + _nodeType = XmlNodeType.None; + retVal = false; + break; + } + _stringValue = null; + _binHexStream = null; + _valueOffset = 0; + _valueCount = 0; + _stringOffset = 0; + CloseStreams(); + return retVal; + } + + public override int ReadValueAsBase64(byte[] buffer, int offset, int count) + { + if (buffer == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(buffer)); + + if (offset < 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative)); + if (offset > buffer.Length) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, buffer.Length))); + if (count < 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative)); + if (count > buffer.Length - offset) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, buffer.Length - offset))); + + if (_stringValue != null) + { + count = Math.Min(count, _valueCount); + if (count > 0) + { + Buffer.BlockCopy(_valueBuffer, _valueOffset, buffer, offset, count); + _valueOffset += count; + _valueCount -= count; + } + return count; + } + + if (_bytesRemaining < count) + count = _bytesRemaining; + + int read = 0; + if (_readState == ReadState.Interactive) + { + while (read < count) + { + int actual = _part.Stream.Read(buffer, offset + read, count - read); + if (actual == 0) + { + _finishedStream = true; + break; + } + read += actual; + } + } + _bytesRemaining -= read; + return read; + } + + public override int ReadContentAsBase64(byte[] buffer, int offset, int count) + { + if (buffer == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(buffer)); + + if (offset < 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative)); + if (offset > buffer.Length) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, buffer.Length))); + if (count < 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative)); + if (count > buffer.Length - offset) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, buffer.Length - offset))); + + if (_valueCount > 0) + { + count = Math.Min(count, _valueCount); + Buffer.BlockCopy(_valueBuffer, _valueOffset, buffer, offset, count); + _valueOffset += count; + _valueCount -= count; + return count; + } + + if (_chunkSize < count) + count = _chunkSize; + + int read = 0; + if (_readState == ReadState.Interactive) + { + while (read < count) + { + int actual = _part.Stream.Read(buffer, offset + read, count - read); + if (actual == 0) + { + _finishedStream = true; + if (!Read()) + break; + } + read += actual; + } + } + _bytesRemaining = _chunkSize; + return read; + } + + public override int ReadContentAsBinHex(byte[] buffer, int offset, int count) + { + if (buffer == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(buffer)); + + if (offset < 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative)); + if (offset > buffer.Length) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, buffer.Length))); + if (count < 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative)); + if (count > buffer.Length - offset) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, buffer.Length - offset))); + + if (_chunkSize < count) + count = _chunkSize; + + int read = 0; + int consumed = 0; + while (read < count) + { + if (_binHexStream == null) + { + try + { + _binHexStream = new MemoryStream(new BinHexEncoding().GetBytes(Value)); + } + catch (FormatException e) // Wrap format exceptions from decoding document contents + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(e.Message, e)); + } + } + + int actual = _binHexStream.Read(buffer, offset + read, count - read); + if (actual == 0) + { + _finishedStream = true; + if (!Read()) + break; + + consumed = 0; + } + + read += actual; + consumed += actual; + } + + // Trim off the consumed chars + if (_stringValue != null && consumed > 0) + { + _stringValue = _stringValue.Substring(consumed * 2); + _stringOffset = Math.Max(0, _stringOffset - consumed * 2); + + _bytesRemaining = _chunkSize; + } + return read; + } + + public override int ReadValueChunk(char[] chars, int offset, int count) + { + if (chars == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(chars)); + + if (offset < 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative)); + if (offset > chars.Length) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, chars.Length))); + if (count < 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative)); + if (count > chars.Length - offset) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, chars.Length - offset))); + + if (_readState != ReadState.Interactive) + return 0; + + // Copy characters from the Value property + string str = Value; + count = Math.Min(_stringValue.Length - _stringOffset, count); + if (count > 0) + { + _stringValue.CopyTo(_stringOffset, chars, offset, count); + _stringOffset += count; + } + return count; + } + + public override string Value + { + get + { + if (_readState != ReadState.Interactive) + return string.Empty; + + if (_stringValue == null) + { + // Compute the bytes to read + int byteCount = _bytesRemaining; + byteCount -= byteCount % 3; + + // Handle trailing bytes + if (_valueCount > 0 && _valueOffset > 0) + { + Buffer.BlockCopy(_valueBuffer, _valueOffset, _valueBuffer, 0, _valueCount); + _valueOffset = 0; + } + byteCount -= _valueCount; + + // Resize buffer if needed + if (_valueBuffer == null) + { + _valueBuffer = new byte[byteCount]; + } + else if (_valueBuffer.Length < byteCount) + { + Array.Resize(ref _valueBuffer, byteCount); + } + byte[] buffer = _valueBuffer; + + // Fill up the buffer + int offset = 0; + int read = 0; + while (byteCount > 0) + { + read = _part.Stream.Read(buffer, offset, byteCount); + if (read == 0) + { + _finishedStream = true; + break; + } + + _bytesRemaining -= read; + _valueCount += read; + byteCount -= read; + offset += read; + } + + // Convert the bytes + _stringValue = Convert.ToBase64String(buffer, 0, _valueCount); + } + return _stringValue; + } + } + + public override string ReadContentAsString() + { + int stringContentQuota = Quotas.MaxStringContentLength; + StringBuilder sb = new StringBuilder(); + do + { + string val = Value; + if (val.Length > stringContentQuota) + XmlExceptionHelper.ThrowMaxStringContentLengthExceeded(this, Quotas.MaxStringContentLength); + stringContentQuota -= val.Length; + sb.Append(val); + } while (Read()); + return sb.ToString(); + } + + public override int AttributeCount + { + get { return 0; } + } + + public override string BaseURI + { + get { return _parentReader.BaseURI; } + } + + public override bool CanReadBinaryContent + { + get { return true; } + } + + public override bool CanReadValueChunk + { + get { return true; } + } + + public override bool CanResolveEntity + { + get { return _parentReader.CanResolveEntity; } + } + + public override void Close() + { + CloseStreams(); + _readState = ReadState.Closed; + } + + private void CloseStreams() + { + if (_binHexStream != null) + { + _binHexStream.Close(); + _binHexStream = null; + } + } + + public override int Depth + { + get + { + return (_readState == ReadState.Interactive) ? _parentReader.Depth + 1 : _parentReader.Depth; + } + } + + public override bool EOF + { + get { return _readState == ReadState.EndOfFile; } + } + + public override string GetAttribute(int index) + { + return null; + } + + public override string GetAttribute(string name) + { + return null; + } + + public override string GetAttribute(string name, string ns) + { + return null; + } + + public override string GetAttribute(XmlDictionaryString localName, XmlDictionaryString ns) + { + return null; + } + + public override bool HasAttributes + { + get { return false; } + } + + public override bool HasValue + { + get { return _readState == ReadState.Interactive; } + } + + public override bool IsDefault + { + get { return false; } + } + + public override bool IsEmptyElement + { + get { return false; } + } + + public override bool IsLocalName(string localName) + { + return false; + } + + public override bool IsLocalName(XmlDictionaryString localName) + { + return false; + } + + public override bool IsNamespaceUri(string ns) + { + return false; + } + + public override bool IsNamespaceUri(XmlDictionaryString ns) + { + return false; + } + + public override bool IsStartElement() + { + return false; + } + + public override bool IsStartElement(string localName) + { + return false; + } + + public override bool IsStartElement(string localName, string ns) + { + return false; + } + + public override bool IsStartElement(XmlDictionaryString localName, XmlDictionaryString ns) + { + return false; + } +#if NO + public override bool IsStartSubsetElement() + { + return false; + } +#endif + public override string LocalName + { + get + { + return (_readState == ReadState.Interactive) ? string.Empty : _parentReader.LocalName; + } + } + + public override string LookupNamespace(string ns) + { + return _parentReader.LookupNamespace(ns); + } + + public override void MoveToAttribute(int index) + { + } + + public override bool MoveToAttribute(string name) + { + return false; + } + + public override bool MoveToAttribute(string name, string ns) + { + return false; + } + + public override bool MoveToElement() + { + return false; + } + + public override bool MoveToFirstAttribute() + { + return false; + } + + public override bool MoveToNextAttribute() + { + return false; + } + + public override string Name + { + get + { + return (_readState == ReadState.Interactive) ? string.Empty : _parentReader.Name; + } + } + + public override string NamespaceURI + { + get + { + return (_readState == ReadState.Interactive) ? string.Empty : _parentReader.NamespaceURI; + } + } + + public override XmlNameTable NameTable + { + get { return _parentReader.NameTable; } + } + + public override string Prefix + { + get + { + return (_readState == ReadState.Interactive) ? string.Empty : _parentReader.Prefix; + } + } + + public override char QuoteChar + { + get { return _parentReader.QuoteChar; } + } + + public override bool ReadAttributeValue() + { + return false; + } + + public override string ReadInnerXml() + { + return ReadContentAsString(); + } + + public override string ReadOuterXml() + { + return ReadContentAsString(); + } + + public override ReadState ReadState + { + get { return _readState; } + } + + public override void ResolveEntity() + { + } + + public override XmlReaderSettings Settings + { + get { return _parentReader.Settings; } + } + + public override void Skip() + { + Read(); + } + + public override string this[int index] + { + get { return null; } + } + + public override string this[string name] + { + get { return null; } + } + + public override string this[string name, string ns] + { + get { return null; } + } + + public override string XmlLang + { + get { return _parentReader.XmlLang; } + } + + public override XmlSpace XmlSpace + { + get { return _parentReader.XmlSpace; } + } + + public override Type ValueType + { + get + { + return (_readState == ReadState.Interactive) ? typeof(byte[]) : _parentReader.ValueType; + } + } + + bool IXmlLineInfo.HasLineInfo() + { + return ((IXmlLineInfo)_parentReader).HasLineInfo(); + } + + int IXmlLineInfo.LineNumber + { + get + { + return ((IXmlLineInfo)_parentReader).LineNumber; + } + } + + int IXmlLineInfo.LinePosition + { + get + { + return ((IXmlLineInfo)_parentReader).LinePosition; + } + } + } + } + + internal class MimeMessageReader + { + private static byte[] CRLFCRLF = new byte[] { (byte)'\r', (byte)'\n', (byte)'\r', (byte)'\n' }; + private bool getContentStreamCalled; + private MimeHeaderReader mimeHeaderReader; + private DelimittedStreamReader reader; + + public MimeMessageReader(Stream stream) + { + if (stream == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(stream)); + + reader = new DelimittedStreamReader(stream); + mimeHeaderReader = new MimeHeaderReader(reader.GetNextStream(CRLFCRLF)); + } + + public Stream GetContentStream() + { + if (getContentStreamCalled) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.MimeMessageGetContentStreamCalledAlready)); + + mimeHeaderReader.Close(); + + Stream s = reader.GetNextStream(null); + + getContentStreamCalled = true; + + return s; + } + + public MimeHeaders ReadHeaders(int maxBuffer, ref int remaining) + { + MimeHeaders headers = new MimeHeaders(); + while (mimeHeaderReader.Read(maxBuffer, ref remaining)) + { + headers.Add(mimeHeaderReader.Name, mimeHeaderReader.Value, ref remaining); + } + return headers; + } + } + + internal class MimeReader + { + private static byte[] CRLFCRLF = new byte[] { (byte)'\r', (byte)'\n', (byte)'\r', (byte)'\n' }; + private byte[] boundaryBytes; + private string content; + private Stream currentStream; + private MimeHeaderReader mimeHeaderReader; + private DelimittedStreamReader reader; + private byte[] scratch = new byte[2]; + + public MimeReader(Stream stream, string boundary) + { + if (stream == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(stream)); + if (boundary == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(boundary)); + + reader = new DelimittedStreamReader(stream); + boundaryBytes = MimeWriter.GetBoundaryBytes(boundary); + + // Need to ensure that the content begins with a CRLF, in case the + // outer construct has consumed the trailing CRLF + reader.Push(boundaryBytes, 0, 2); + } + + public void Close() + { + reader.Close(); + } + + /// Gets the content preceding the first part of the MIME multi-part message + public string Preface + { + get + { + if (content == null) + { + Stream s = reader.GetNextStream(boundaryBytes); + content = new StreamReader(s, System.Text.Encoding.ASCII, false, 256).ReadToEnd(); + s.Close(); + if (content == null) + content = string.Empty; + } + return content; + } + } + + public Stream GetContentStream() + { + Fx.Assert(content != null, ""); + + mimeHeaderReader.Close(); + + return reader.GetNextStream(boundaryBytes); + } + + public bool ReadNextPart() + { + string content = Preface; + + if (currentStream != null) + { + currentStream.Close(); + currentStream = null; + } + + Stream stream = reader.GetNextStream(CRLFCRLF); + + if (stream == null) + return false; + + if (BlockRead(stream, scratch, 0, 2) == 2) + { + if (scratch[0] == '\r' && scratch[1] == '\n') + { + if (mimeHeaderReader == null) + mimeHeaderReader = new MimeHeaderReader(stream); + else + mimeHeaderReader.Reset(stream); + return true; + } + else if (scratch[0] == '-' && scratch[1] == '-') + { + int read = BlockRead(stream, scratch, 0, 2); + + if (read < 2 || (scratch[0] == '\r' && scratch[1] == '\n')) + return false; + } + } + + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.MimeReaderTruncated)); + } + + public MimeHeaders ReadHeaders(int maxBuffer, ref int remaining) + { + MimeHeaders headers = new MimeHeaders(); + while (mimeHeaderReader.Read(maxBuffer, ref remaining)) + { + headers.Add(mimeHeaderReader.Name, mimeHeaderReader.Value, ref remaining); + } + return headers; + } + + private int BlockRead(Stream stream, byte[] buffer, int offset, int count) + { + int read = 0; + do + { + int r = stream.Read(buffer, offset + read, count - read); + if (r == 0) + break; + read += r; + } while (read < count); + return read; + } + + } + + internal class DelimittedStreamReader + { + private bool canGetNextStream = true; + + // used for closing the reader, and validating that only one stream can be reading at a time. + private DelimittedReadStream currentStream; + private byte[] delimitter; + private byte[] matchBuffer; + private byte[] scratch; + private BufferedReadStream stream; + + public DelimittedStreamReader(Stream stream) + { + this.stream = new BufferedReadStream(stream); + } + + public void Close() + { + stream.Close(); + } + + // Closes the current stream. If the current stream is not the same as the caller, nothing is done. + private void Close(DelimittedReadStream caller) + { + if (currentStream == caller) + { + if (delimitter == null) + { + stream.Close(); + } + else + { + if (scratch == null) + { + scratch = new byte[1024]; + } + while (0 != Read(caller, scratch, 0, scratch.Length)) + ; + } + + currentStream = null; + } + } + + // Gets the next logical stream delimitted by the given sequence. + public Stream GetNextStream(byte[] delimitter) + { + if (currentStream != null) + { + currentStream.Close(); + currentStream = null; + } + + if (!canGetNextStream) + return null; + + this.delimitter = delimitter; + + canGetNextStream = delimitter != null; + + currentStream = new DelimittedReadStream(this); + + return currentStream; + } + + private enum MatchState + { + True, + False, + InsufficientData + } + + private MatchState MatchDelimitter(byte[] buffer, int start, int end) + { + if (delimitter.Length > end - start) + { + for (int i = end - start - 1; i >= 1; i--) + { + if (buffer[start + i] != delimitter[i]) + return MatchState.False; + } + return MatchState.InsufficientData; + } + for (int i = delimitter.Length - 1; i >= 1; i--) + { + if (buffer[start + i] != delimitter[i]) + return MatchState.False; + } + return MatchState.True; + } + + private int ProcessRead(byte[] buffer, int offset, int read) + { + // nothing to process if 0 bytes were read + if (read == 0) + return read; + + for (int ptr = offset, end = offset + read; ptr < end; ptr++) + { + if (buffer[ptr] == delimitter[0]) + { + switch (MatchDelimitter(buffer, ptr, end)) + { + case MatchState.True: + { + int actual = ptr - offset; + ptr += delimitter.Length; + stream.Push(buffer, ptr, end - ptr); + currentStream = null; + return actual; + } + case MatchState.False: + break; + case MatchState.InsufficientData: + { + int actual = ptr - offset; + if (actual > 0) + { + stream.Push(buffer, ptr, end - ptr); + return actual; + } + else + { + return -1; + } + } + } + } + } + return read; + } + + private int Read(DelimittedReadStream caller, byte[] buffer, int offset, int count) + { + if (currentStream != caller) + return 0; + + int read = stream.Read(buffer, offset, count); + if (read == 0) + { + canGetNextStream = false; + currentStream = null; + return read; + } + + // If delimitter is null, read until the underlying stream returns 0 bytes + if (delimitter == null) + return read; + + // Scans the read data for the delimitter. If found, the number of bytes read are adjusted + // to account for the number of bytes up to but not including the delimitter. + int actual = ProcessRead(buffer, offset, read); + + if (actual < 0) + { + if (matchBuffer == null || matchBuffer.Length < delimitter.Length - read) + matchBuffer = new byte[delimitter.Length - read]; + + int matched = stream.ReadBlock(matchBuffer, 0, delimitter.Length - read); + + if (MatchRemainder(read, matched)) + { + currentStream = null; + actual = 0; + } + else + { + stream.Push(matchBuffer, 0, matched); + + int i = 1; + for (; i < read; i++) + { + if (buffer[i] == delimitter[0]) + break; + } + + if (i < read) + stream.Push(buffer, offset + i, read - i); + + actual = i; + } + } + + return actual; + } + + private bool MatchRemainder(int start, int count) + { + if (start + count != delimitter.Length) + return false; + + for (count--; count >= 0; count--) + { + if (delimitter[start + count] != matchBuffer[count]) + return false; + } + return true; + } + + internal void Push(byte[] buffer, int offset, int count) + { + stream.Push(buffer, offset, count); + } + + private class DelimittedReadStream : Stream + { + private DelimittedStreamReader reader; + + public DelimittedReadStream(DelimittedStreamReader reader) + { + if (reader == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(reader)); + + this.reader = reader; + } + + public override bool CanRead + { + get { return true; } + } + + public override bool CanSeek + { + get { return false; } + } + + public override bool CanWrite + { + get { return false; } + } + + public override long Length + { +#pragma warning suppress 56503 // sowmys, required by the XmlReader + get { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.SeekNotSupportedOnStream, GetType().FullName))); } + } + + public override long Position + { + get + { +#pragma warning suppress 56503 // sowmys, required by the XmlReader + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.SeekNotSupportedOnStream, GetType().FullName))); + } + set { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.SeekNotSupportedOnStream, GetType().FullName))); } + } + + public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.WriteNotSupportedOnStream, GetType().FullName))); + } + + public override void Close() + { + reader.Close(this); + } + + public override void EndWrite(IAsyncResult asyncResult) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.WriteNotSupportedOnStream, GetType().FullName))); + } + + public override void Flush() + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.WriteNotSupportedOnStream, GetType().FullName))); + } + + public override int Read(byte[] buffer, int offset, int count) + { + if (buffer == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(buffer)); + + if (offset < 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative)); + if (offset > buffer.Length) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, buffer.Length))); + if (count < 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative)); + if (count > buffer.Length - offset) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, buffer.Length - offset))); + + return reader.Read(this, buffer, offset, count); + } + + public override long Seek(long offset, SeekOrigin origin) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.SeekNotSupportedOnStream, GetType().FullName))); + } + + public override void SetLength(long value) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.WriteNotSupportedOnStream, GetType().FullName))); + } + + public override void Write(byte[] buffer, int offset, int count) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.WriteNotSupportedOnStream, GetType().FullName))); + } + } + + } + + internal class MimeHeaders + { + private static class Constants + { + public const string ContentTransferEncoding = "content-transfer-encoding"; + public const string ContentID = "content-id"; + public const string ContentType = "content-type"; + public const string MimeVersion = "mime-version"; + } + + private Dictionary headers = new Dictionary(); + + public MimeHeaders() + { + } + + public ContentTypeHeader ContentType + { + get + { + MimeHeader header; + if (headers.TryGetValue(Constants.ContentType, out header)) + return header as ContentTypeHeader; + return null; + } + } + + public ContentIDHeader ContentID + { + get + { + MimeHeader header; + if (headers.TryGetValue(Constants.ContentID, out header)) + return header as ContentIDHeader; + return null; + } + } + + public ContentTransferEncodingHeader ContentTransferEncoding + { + get + { + MimeHeader header; + if (headers.TryGetValue(Constants.ContentTransferEncoding, out header)) + return header as ContentTransferEncodingHeader; + return null; + } + } + + public MimeVersionHeader MimeVersion + { + get + { + MimeHeader header; + if (headers.TryGetValue(Constants.MimeVersion, out header)) + return header as MimeVersionHeader; + return null; + } + } + + public void Add(string name, string value, ref int remaining) + { + if (name == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(name)); + + if (value == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value)); + + switch (name) + { + case Constants.ContentType: + Add(new ContentTypeHeader(value)); + break; + case Constants.ContentID: + Add(new ContentIDHeader(name, value)); + break; + case Constants.ContentTransferEncoding: + Add(new ContentTransferEncodingHeader(value)); + break; + case Constants.MimeVersion: + Add(new MimeVersionHeader(value)); + break; + + // Skip any fields that are not recognized + // Content-description is currently not stored since it is not used + default: + remaining += value.Length * sizeof(char); + break; + } + remaining += name.Length * sizeof(char); + } + + public void Add(MimeHeader header) + { + if (header == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(header)); + + MimeHeader existingHeader; + if (headers.TryGetValue(header.Name, out existingHeader)) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.Format(SR.MimeReaderHeaderAlreadyExists, header.Name))); + else + headers.Add(header.Name, header); + } + + public void Release(ref int remaining) + { + foreach (MimeHeader header in headers.Values) + { + remaining += header.Value.Length * sizeof(char); + } + } + + } + + internal class MimeHeader + { + private string name; + private string value; + + public MimeHeader(string name, string value) + { + if (name == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(name)); + + this.name = name; + this.value = value; + } + + public string Name + { + get + { + return name; + } + } + + public string Value + { + get + { + return value; + } + } + } + + internal class ContentTypeHeader : MimeHeader + { + public static readonly ContentTypeHeader Default = new ContentTypeHeader("application/octet-stream"); + + public ContentTypeHeader(string value) + : base("content-type", value) + { + } + + private string mediaType; + private string subType; + private Dictionary parameters; + + public string MediaType + { + get + { + if (mediaType == null && Value != null) + ParseValue(); + + return mediaType; + } + } + + public string MediaSubtype + { + get + { + if (subType == null && Value != null) + ParseValue(); + + return subType; + } + } + + public Dictionary Parameters + { + get + { + if (parameters == null) + { + if (Value != null) + ParseValue(); + else + parameters = new Dictionary(); + } + return parameters; + } + } + + private void ParseValue() + { + if (parameters == null) + { + int offset = 0; + parameters = new Dictionary(); + mediaType = MailBnfHelper.ReadToken(Value, ref offset, null); + if (offset >= Value.Length || Value[offset++] != '/') + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.MimeContentTypeHeaderInvalid)); + subType = MailBnfHelper.ReadToken(Value, ref offset, null); + + while (MailBnfHelper.SkipCFWS(Value, ref offset)) + { + if (offset >= Value.Length || Value[offset++] != ';') + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.MimeContentTypeHeaderInvalid)); + + if (!MailBnfHelper.SkipCFWS(Value, ref offset)) + break; + + string paramAttribute = MailBnfHelper.ReadParameterAttribute(Value, ref offset, null); + if (paramAttribute == null || offset >= Value.Length || Value[offset++] != '=') + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.MimeContentTypeHeaderInvalid)); + string paramValue = MailBnfHelper.ReadParameterValue(Value, ref offset, null); + + parameters.Add(paramAttribute.ToLowerInvariant(), paramValue); + } + + if (parameters.ContainsKey(MtomGlobals.StartInfoParam)) + { + // This allows us to maintain back compat with Orcas clients while allowing clients + // following the spec (with action inside start-info) to interop with RFC 2387 + string startInfo = parameters[MtomGlobals.StartInfoParam]; + + // we're only interested in finding the action here - skipping past the content type to the first ; + int startInfoOffset = startInfo.IndexOf(';'); + if (startInfoOffset > -1) + { + // keep going through the start-info string until we've reached the end of the stream + while (MailBnfHelper.SkipCFWS(startInfo, ref startInfoOffset)) + { + // after having read through an attribute=value pair, we always expect to be at a ; + if (startInfo[startInfoOffset] == ';') + { + startInfoOffset++; + } + else + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.MimeContentTypeHeaderInvalid)); + } + string paramAttribute = MailBnfHelper.ReadParameterAttribute(startInfo, ref startInfoOffset, null); + if (paramAttribute == null || startInfoOffset >= startInfo.Length || startInfo[startInfoOffset++] != '=') + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.MimeContentTypeHeaderInvalid)); + string paramValue = MailBnfHelper.ReadParameterValue(startInfo, ref startInfoOffset, null); + + if (paramAttribute == MtomGlobals.ActionParam) + { + parameters[MtomGlobals.ActionParam] = paramValue; + } + } + } + } + + } + } + } + + internal enum ContentTransferEncoding + { + SevenBit, + EightBit, + Binary, + Other, + Unspecified + } + + internal class ContentTransferEncodingHeader : MimeHeader + { + private ContentTransferEncoding contentTransferEncoding; + private string contentTransferEncodingValue; + + public static readonly ContentTransferEncodingHeader Binary = new ContentTransferEncodingHeader(ContentTransferEncoding.Binary, "binary"); + public static readonly ContentTransferEncodingHeader EightBit = new ContentTransferEncodingHeader(ContentTransferEncoding.EightBit, "8bit"); + public static readonly ContentTransferEncodingHeader SevenBit = new ContentTransferEncodingHeader(ContentTransferEncoding.SevenBit, "7bit"); + + public ContentTransferEncodingHeader(string value) + : base("content-transfer-encoding", value.ToLowerInvariant()) + { + } + + public ContentTransferEncodingHeader(ContentTransferEncoding contentTransferEncoding, string value) + : base("content-transfer-encoding", null) + { + this.contentTransferEncoding = contentTransferEncoding; + contentTransferEncodingValue = value; + } + + public ContentTransferEncoding ContentTransferEncoding + { + get + { + ParseValue(); + return contentTransferEncoding; + } + } + + public string ContentTransferEncodingValue + { + get + { + ParseValue(); + return contentTransferEncodingValue; + } + } + + private void ParseValue() + { + if (contentTransferEncodingValue == null) + { + int offset = 0; + contentTransferEncodingValue = (Value.Length == 0) ? Value : ((Value[0] == '"') ? MailBnfHelper.ReadQuotedString(Value, ref offset, null) : MailBnfHelper.ReadToken(Value, ref offset, null)); + switch (contentTransferEncodingValue) + { + case "7bit": + contentTransferEncoding = ContentTransferEncoding.SevenBit; + break; + case "8bit": + contentTransferEncoding = ContentTransferEncoding.EightBit; + break; + case "binary": + contentTransferEncoding = ContentTransferEncoding.Binary; + break; + default: + contentTransferEncoding = ContentTransferEncoding.Other; + break; + } + } + } + } + + internal class ContentIDHeader : MimeHeader + { + public ContentIDHeader(string name, string value) + : base(name, value) + { + } + } + + internal class MimeVersionHeader : MimeHeader + { + public static readonly MimeVersionHeader Default = new MimeVersionHeader("1.0"); + + public MimeVersionHeader(string value) + : base("mime-version", value) + { + } + + private string version; + + public string Version + { + get + { + if (version == null && Value != null) + ParseValue(); + return version; + } + } + + private void ParseValue() + { + // shortcut for the most common case. + if (Value == "1.0") + { + version = "1.0"; + } + else + { + int offset = 0; + + if (!MailBnfHelper.SkipCFWS(Value, ref offset)) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.MimeVersionHeaderInvalid)); + + StringBuilder builder = new StringBuilder(); + MailBnfHelper.ReadDigits(Value, ref offset, builder); + + if ((!MailBnfHelper.SkipCFWS(Value, ref offset) || offset >= Value.Length || Value[offset++] != '.') || !MailBnfHelper.SkipCFWS(Value, ref offset)) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.MimeVersionHeaderInvalid)); + + builder.Append('.'); + + MailBnfHelper.ReadDigits(Value, ref offset, builder); + + version = builder.ToString(); + } + } + } + + internal class MimeHeaderReader + { + private enum ReadState + { + ReadName, + SkipWS, + ReadValue, + ReadLF, + ReadWS, + EOF + } + + private string value; + private byte[] buffer = new byte[1024]; + private int maxOffset; + private string name; + private int offset; + private ReadState readState = ReadState.ReadName; + private Stream stream; + + public MimeHeaderReader(Stream stream) + { + if (stream == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(stream)); + + this.stream = stream; + } + + public string Value + { + get + { + return value; + } + } + + public string Name + { + get + { + return name; + } + } + + public void Close() + { + stream.Close(); + readState = ReadState.EOF; + } + + public bool Read(int maxBuffer, ref int remaining) + { + name = null; + value = null; + + while (readState != ReadState.EOF) + { + if (offset == maxOffset) + { + maxOffset = stream.Read(buffer, 0, buffer.Length); + offset = 0; + if (BufferEnd()) + break; + } + if (ProcessBuffer(maxBuffer, ref remaining)) + break; + } + + return value != null; + } + + [Fx.Tag.SecurityNote(Critical = "Calls unsafe code", Safe = "Demands for FullTrust")] + [SecuritySafeCritical] + [PermissionSet(SecurityAction.Demand, Unrestricted = true)] + private bool ProcessBuffer(int maxBuffer, ref int remaining) + { + unsafe + { + fixed (byte* pBuffer = buffer) + { + byte* start = pBuffer + offset; + byte* end = pBuffer + maxOffset; + byte* ptr = start; + + switch (readState) + { + case ReadState.ReadName: + for (; ptr < end; ptr++) + { + if (*ptr == ':') + { + AppendName(new string((sbyte*)start, 0, (int)(ptr - start)), maxBuffer, ref remaining); + ptr++; + goto case ReadState.SkipWS; + } + else + { + // convert to lower case up front. + if (*ptr >= 'A' && *ptr <= 'Z') + { + *ptr += 'a' - 'A'; + } + else if (*ptr < 33 || *ptr > 126) + { + if (name == null && *ptr == (byte)'\r') + { + ptr++; + if (ptr >= end || *ptr != '\n') + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.MimeReaderMalformedHeader)); + goto case ReadState.EOF; + } + + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.Format(SR.MimeHeaderInvalidCharacter, (char)(*ptr), ((int)(*ptr)).ToString("X", CultureInfo.InvariantCulture)))); + } + } + } + AppendName(new string((sbyte*)start, 0, (int)(ptr - start)), maxBuffer, ref remaining); + readState = ReadState.ReadName; + break; + case ReadState.SkipWS: + for (; ptr < end; ptr++) + if (*ptr != (byte)'\t' && *ptr != ' ') + goto case ReadState.ReadValue; + readState = ReadState.SkipWS; + break; + case ReadState.ReadValue: + start = ptr; + for (; ptr < end; ptr++) + { + if (*ptr == (byte)'\r') + { + AppendValue(new string((sbyte*)start, 0, (int)(ptr - start)), maxBuffer, ref remaining); + ptr++; + goto case ReadState.ReadLF; + } + else if (*ptr == (byte)'\n') + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.MimeReaderMalformedHeader)); + } + } + AppendValue(new string((sbyte*)start, 0, (int)(ptr - start)), maxBuffer, ref remaining); + readState = ReadState.ReadValue; + break; + case ReadState.ReadLF: + if (ptr < end) + { + if (*ptr != (byte)'\n') + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.MimeReaderMalformedHeader)); + ptr++; + goto case ReadState.ReadWS; + } + readState = ReadState.ReadLF; + break; + case ReadState.ReadWS: + if (ptr < end) + { + if (*ptr != (byte)' ' && *ptr != (byte)'\t') + { + readState = ReadState.ReadName; + offset = (int)(ptr - pBuffer); + return true; + } + goto case ReadState.ReadValue; + } + readState = ReadState.ReadWS; + break; + case ReadState.EOF: + readState = ReadState.EOF; + offset = (int)(ptr - pBuffer); + return true; + } + offset = (int)(ptr - pBuffer); + } + } + return false; + } + + private bool BufferEnd() + { + if (maxOffset == 0) + { + if (readState != ReadState.ReadWS && readState != ReadState.ReadValue) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.MimeReaderMalformedHeader)); + + readState = ReadState.EOF; + return true; + } + return false; + } + + // Resets the mail field reader to the new stream to reuse buffers + public void Reset(Stream stream) + { + if (stream == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(stream)); + + if (readState != ReadState.EOF) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.MimeReaderResetCalledBeforeEOF)); + + this.stream = stream; + readState = ReadState.ReadName; + maxOffset = 0; + offset = 0; + } + + // helper methods + + private void AppendValue(string value, int maxBuffer, ref int remaining) + { + XmlMtomReader.DecrementBufferQuota(maxBuffer, ref remaining, value.Length * sizeof(char)); + if (this.value == null) + this.value = value; + else + this.value += value; + } + + private void AppendName(string value, int maxBuffer, ref int remaining) + { + XmlMtomReader.DecrementBufferQuota(maxBuffer, ref remaining, value.Length * sizeof(char)); + if (name == null) + name = value; + else + name += value; + } + + } + + internal class BufferedReadStream : Stream + { + private Stream stream; + private byte[] storedBuffer; + private int storedLength; + private int storedOffset; + private bool readMore; + + public BufferedReadStream(Stream stream) + : this(stream, false) + { + } + + public BufferedReadStream(Stream stream, bool readMore) + { + if (stream == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(stream)); + + this.stream = stream; + this.readMore = readMore; + } + + public override bool CanWrite + { + get { return false; } + } + + public override bool CanSeek + { + get { return false; } + } + + public override bool CanRead + { + get { return stream.CanRead; } + } + + public override long Length + { + get + { +#pragma warning suppress 56503 // sowmys, required by the Stream contract + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.SeekNotSupportedOnStream, stream.GetType().FullName))); + } + } + + public override long Position + { + get + { +#pragma warning suppress 56503 // sowmys, required by the Stream contract + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.SeekNotSupportedOnStream, stream.GetType().FullName))); + } + set + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.SeekNotSupportedOnStream, stream.GetType().FullName))); + } + } + + public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) + { + if (!CanRead) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.ReadNotSupportedOnStream, stream.GetType().FullName))); + + return stream.BeginRead(buffer, offset, count, callback, state); + } + + public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.WriteNotSupportedOnStream, stream.GetType().FullName))); + } + + public override void Close() + { + stream.Close(); + } + + public override int EndRead(IAsyncResult asyncResult) + { + if (!CanRead) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.ReadNotSupportedOnStream, stream.GetType().FullName))); + + return stream.EndRead(asyncResult); + } + + public override void EndWrite(IAsyncResult asyncResult) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.WriteNotSupportedOnStream, stream.GetType().FullName))); + } + + public override void Flush() + { + stream.Flush(); + } + + public override int Read(byte[] buffer, int offset, int count) + { + if (!CanRead) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.ReadNotSupportedOnStream, stream.GetType().FullName))); + + if (buffer == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(buffer)); + + if (offset < 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative)); + if (offset > buffer.Length) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, buffer.Length))); + if (count < 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative)); + if (count > buffer.Length - offset) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, buffer.Length - offset))); + + int read = 0; + if (storedOffset < storedLength) + { + read = Math.Min(count, storedLength - storedOffset); + Buffer.BlockCopy(storedBuffer, storedOffset, buffer, offset, read); + storedOffset += read; + if (read == count || !readMore) + return read; + offset += read; + count -= read; + } + return read + stream.Read(buffer, offset, count); + } + + public override int ReadByte() + { + if (storedOffset < storedLength) + return (int)storedBuffer[storedOffset++]; + else + return base.ReadByte(); + } + + public int ReadBlock(byte[] buffer, int offset, int count) + { + int read; + int total = 0; + while (total < count && (read = Read(buffer, offset + total, count - total)) != 0) + { + total += read; + } + return total; + } + + public void Push(byte[] buffer, int offset, int count) + { + if (count == 0) + return; + + if (storedOffset == storedLength) + { + if (storedBuffer == null || storedBuffer.Length < count) + storedBuffer = new byte[count]; + storedOffset = 0; + storedLength = count; + } + else + { + // if there's room to just insert before existing data + if (count <= storedOffset) + storedOffset -= count; + // if there's room in the buffer but need to shift things over + else if (count <= storedBuffer.Length - storedLength + storedOffset) + { + Buffer.BlockCopy(storedBuffer, storedOffset, storedBuffer, count, storedLength - storedOffset); + storedLength += count - storedOffset; + storedOffset = 0; + } + else + { + byte[] newBuffer = new byte[count + storedLength - storedOffset]; + Buffer.BlockCopy(storedBuffer, storedOffset, newBuffer, count, storedLength - storedOffset); + storedLength += count - storedOffset; + storedOffset = 0; + storedBuffer = newBuffer; + } + } + Buffer.BlockCopy(buffer, offset, storedBuffer, storedOffset, count); + } + + public override long Seek(long offset, SeekOrigin origin) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.SeekNotSupportedOnStream, stream.GetType().FullName))); + } + + public override void SetLength(long value) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.SeekNotSupportedOnStream, stream.GetType().FullName))); + } + + public override void Write(byte[] buffer, int offset, int count) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.WriteNotSupportedOnStream, stream.GetType().FullName))); + } + } + + internal static class MailBnfHelper + { + private static bool[] s_fqtext = new bool[128]; + private static bool[] s_ttext = new bool[128]; + private static bool[] s_digits = new bool[128]; + private static bool[] s_boundary = new bool[128]; + + static MailBnfHelper() + { + // fqtext = %d1-9 / %d11 / %d12 / %d14-33 / %d35-91 / %d93-127 + for (int i = 1; i <= 9; i++) + { s_fqtext[i] = true; } + s_fqtext[11] = true; + s_fqtext[12] = true; + for (int i = 14; i <= 33; i++) + { s_fqtext[i] = true; } + for (int i = 35; i <= 91; i++) + { s_fqtext[i] = true; } + for (int i = 93; i <= 127; i++) + { s_fqtext[i] = true; } + + // ttext = %d33-126 except '()<>@,;:\"/[]?=' + for (int i = 33; i <= 126; i++) + { s_ttext[i] = true; } + s_ttext['('] = false; + s_ttext[')'] = false; + s_ttext['<'] = false; + s_ttext['>'] = false; + s_ttext['@'] = false; + s_ttext[','] = false; + s_ttext[';'] = false; + s_ttext[':'] = false; + s_ttext['\\'] = false; + s_ttext['"'] = false; + s_ttext['/'] = false; + s_ttext['['] = false; + s_ttext[']'] = false; + s_ttext['?'] = false; + s_ttext['='] = false; + + // digits = %d48-57 + for (int i = 48; i <= 57; i++) + s_digits[i] = true; + + // boundary = DIGIT / ALPHA / "'" / "(" / ")" / "+" / "_" / "," / "-" / "." / "/" / ":" / "=" / "?" / " " + // cannot end with " " + for (int i = '0'; i <= '9'; i++) + { s_boundary[i] = true; } + for (int i = 'A'; i <= 'Z'; i++) + { s_boundary[i] = true; } + for (int i = 'a'; i <= 'z'; i++) + { s_boundary[i] = true; } + s_boundary['\''] = true; + s_boundary['('] = true; + s_boundary[')'] = true; + s_boundary['+'] = true; + s_boundary['_'] = true; + s_boundary[','] = true; + s_boundary['-'] = true; + s_boundary['.'] = true; + s_boundary['/'] = true; + s_boundary[':'] = true; + s_boundary['='] = true; + s_boundary['?'] = true; + s_boundary[' '] = true; + } + + public static bool SkipCFWS(string data, ref int offset) + { + int comments = 0; + for (; offset < data.Length; offset++) + { + if (data[offset] > 127) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.Format(SR.MimeHeaderInvalidCharacter, data[offset], ((int)data[offset]).ToString("X", CultureInfo.InvariantCulture)))); + else if (data[offset] == '\\' && comments > 0) + offset += 2; + else if (data[offset] == '(') + comments++; + else if (data[offset] == ')') + comments--; + else if (data[offset] != ' ' && data[offset] != '\t' && comments == 0) + return true; + } + return false; + } + + public static string ReadQuotedString(string data, ref int offset, StringBuilder builder) + { + // assume first char is the opening quote + int start = ++offset; + StringBuilder localBuilder = (builder != null ? builder : new StringBuilder()); + for (; offset < data.Length; offset++) + { + if (data[offset] == '\\') + { + localBuilder.Append(data, start, offset - start); + start = ++offset; + continue; + } + else if (data[offset] == '"') + { + localBuilder.Append(data, start, offset - start); + offset++; + return (builder != null ? null : localBuilder.ToString()); + } + else if (!(data[offset] < s_fqtext.Length && s_fqtext[data[offset]])) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.Format(SR.MimeHeaderInvalidCharacter, data[offset], ((int)data[offset]).ToString("X", CultureInfo.InvariantCulture)))); + } + } + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.MimeReaderMalformedHeader)); + } + + public static string ReadParameterAttribute(string data, ref int offset, StringBuilder builder) + { + if (!SkipCFWS(data, ref offset)) + return null; + + return ReadToken(data, ref offset, null); + } + + public static string ReadParameterValue(string data, ref int offset, StringBuilder builder) + { + if (!SkipCFWS(data, ref offset)) + return string.Empty; + + if (offset < data.Length && data[offset] == '"') + return ReadQuotedString(data, ref offset, builder); + else + return ReadToken(data, ref offset, builder); + } + + public static string ReadToken(string data, ref int offset, StringBuilder builder) + { + int start = offset; + for (; offset < data.Length; offset++) + { + if (data[offset] > s_ttext.Length) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.Format(SR.MimeHeaderInvalidCharacter, data[offset], ((int)data[offset]).ToString("X", CultureInfo.InvariantCulture)))); + } + else if (!s_ttext[data[offset]]) + { + break; + } + } + return data.Substring(start, offset - start); + } + + public static string ReadDigits(string data, ref int offset, StringBuilder builder) + { + int start = offset; + StringBuilder localBuilder = (builder != null ? builder : new StringBuilder()); + for (; offset < data.Length && data[offset] < s_digits.Length && s_digits[data[offset]]; offset++) + ; + localBuilder.Append(data, start, offset - start); + return (builder != null ? null : localBuilder.ToString()); + } + + public static bool IsValidMimeBoundary(string data) + { + int length = (data == null) ? 0 : data.Length; + if (length == 0 || length > 70 || data[length - 1] == ' ') + return false; + + for (int i = 0; i < length; i++) + { + if (!(data[i] < s_boundary.Length && s_boundary[data[i]])) + return false; + } + + return true; + } + } +} diff --git a/src/System.Private.ServiceModel/src/Internals/System/Xml/XmlMtomWriter.cs b/src/System.Private.ServiceModel/src/Internals/System/Xml/XmlMtomWriter.cs new file mode 100644 index 00000000000..136d4ead913 --- /dev/null +++ b/src/System.Private.ServiceModel/src/Internals/System/Xml/XmlMtomWriter.cs @@ -0,0 +1,1553 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Xml; +using System.Xml.XPath; +using System.IO; +using System.Text; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Runtime.Serialization; +using System.ServiceModel; +using System.Threading.Tasks; + +namespace System.Xml +{ + internal interface IXmlMtomWriterInitializer + { + void SetOutput(Stream stream, Encoding encoding, int maxSizeInBytes, string startInfo, string boundary, string startUri, bool writeMessageHeaders, bool ownsStream); + } + + internal class XmlMtomWriter : XmlDictionaryWriter, IXmlMtomWriterInitializer + { + public static XmlDictionaryWriter Create(Stream stream, Encoding encoding, int maxSizeInBytes, string startInfo) + { + return Create(stream, encoding, maxSizeInBytes, startInfo, null, null, true, true); + } + + public static XmlDictionaryWriter Create(Stream stream, Encoding encoding, int maxSizeInBytes, string startInfo, string boundary, string startUri, bool writeMessageHeaders, bool ownsStream) + { + XmlMtomWriter writer = new XmlMtomWriter(); + writer.SetOutput(stream, encoding, maxSizeInBytes, startInfo, boundary, startUri, writeMessageHeaders, ownsStream); + return writer; + } + + // Maximum number of bytes that are inlined as base64 data without being MTOM-optimized as xop:Include + private const int MaxInlinedBytes = 767; // 768 will be the first MIMEd length + + private int _maxSizeInBytes; + private XmlDictionaryWriter _writer; + private XmlDictionaryWriter _infosetWriter; + private MimeWriter _mimeWriter; + private Encoding _encoding; + private bool _isUTF8; + private string _contentID; + private string _contentType; + private string _initialContentTypeForRootPart; + private string _initialContentTypeForMimeMessage; + private MemoryStream _contentTypeStream; + private List _mimeParts; + private IList _binaryDataChunks; + private int _depth; + private int _totalSizeOfMimeParts; + private int _sizeOfBufferedBinaryData; + private char[] _chars; + private byte[] _bytes; + private bool _isClosed; + private bool _ownsStream; + + public XmlMtomWriter() + { + } + + public void SetOutput(Stream stream, Encoding encoding, int maxSizeInBytes, string startInfo, string boundary, string startUri, bool writeMessageHeaders, bool ownsStream) + { + if (encoding == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(encoding)); + if (maxSizeInBytes < 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(maxSizeInBytes), SR.ValueMustBeNonNegative)); + _maxSizeInBytes = maxSizeInBytes; + _encoding = encoding; + _isUTF8 = IsUTF8Encoding(encoding); + Initialize(stream, startInfo, boundary, startUri, writeMessageHeaders, ownsStream); + } + + private XmlDictionaryWriter Writer + { + get + { + if (!IsInitialized) + { + Initialize(); + } + return _writer; + } + } + + private bool IsInitialized + { + get { return (_initialContentTypeForRootPart == null); } + } + + private void Initialize(Stream stream, string startInfo, string boundary, string startUri, bool writeMessageHeaders, bool ownsStream) + { + if (stream == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(stream)); + if (startInfo == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(startInfo)); + if (boundary == null) + boundary = GetBoundaryString(); + if (startUri == null) + startUri = GenerateUriForMimePart(0); + if (!MailBnfHelper.IsValidMimeBoundary(boundary)) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.MtomBoundaryInvalid, boundary), nameof(boundary))); + + _ownsStream = ownsStream; + _isClosed = false; + _depth = 0; + _totalSizeOfMimeParts = 0; + _sizeOfBufferedBinaryData = 0; + _binaryDataChunks = null; + _contentType = null; + _contentTypeStream = null; + _contentID = startUri; + if (_mimeParts != null) + _mimeParts.Clear(); + _mimeWriter = new MimeWriter(stream, boundary); + _initialContentTypeForRootPart = GetContentTypeForRootMimePart(_encoding, startInfo); + if (writeMessageHeaders) + _initialContentTypeForMimeMessage = GetContentTypeForMimeMessage(boundary, startUri, startInfo); + } + + private void Initialize() + { + if (_isClosed) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlWriterClosed)); + + if (_initialContentTypeForRootPart != null) + { + if (_initialContentTypeForMimeMessage != null) + { + _mimeWriter.StartPreface(); + _mimeWriter.WriteHeader(MimeGlobals.MimeVersionHeader, MimeGlobals.DefaultVersion); + _mimeWriter.WriteHeader(MimeGlobals.ContentTypeHeader, _initialContentTypeForMimeMessage); + _initialContentTypeForMimeMessage = null; + } + + WriteMimeHeaders(_contentID, _initialContentTypeForRootPart, _isUTF8 ? MimeGlobals.Encoding8bit : MimeGlobals.EncodingBinary); + + Stream infosetContentStream = _mimeWriter.GetContentStreamAsync().GetAwaiter().GetResult(); + IXmlTextWriterInitializer initializer = _writer as IXmlTextWriterInitializer; + if (initializer == null) + _writer = XmlDictionaryWriter.CreateTextWriter(infosetContentStream, _encoding, _ownsStream); + else + initializer.SetOutput(infosetContentStream, _encoding, _ownsStream); + + _contentID = null; + _initialContentTypeForRootPart = null; + } + } + + private static string GetBoundaryString() + { + return MimeBoundaryGenerator.Next(); + } + + internal static bool IsUTF8Encoding(Encoding encoding) + { + return encoding.WebName == "utf-8"; + } + + private static string GetContentTypeForMimeMessage(string boundary, string startUri, string startInfo) + { + StringBuilder contentTypeBuilder = new StringBuilder( + string.Format(CultureInfo.InvariantCulture, "{0}/{1};{2}=\"{3}\";{4}=\"{5}\"", + MtomGlobals.MediaType, MtomGlobals.MediaSubtype, + MtomGlobals.TypeParam, MtomGlobals.XopType, + MtomGlobals.BoundaryParam, boundary)); + + if (startUri != null && startUri.Length > 0) + contentTypeBuilder.AppendFormat(CultureInfo.InvariantCulture, ";{0}=\"<{1}>\"", MtomGlobals.StartParam, startUri); + + if (startInfo != null && startInfo.Length > 0) + contentTypeBuilder.AppendFormat(CultureInfo.InvariantCulture, ";{0}=\"{1}\"", MtomGlobals.StartInfoParam, startInfo); + + return contentTypeBuilder.ToString(); + } + + private static string GetContentTypeForRootMimePart(Encoding encoding, string startInfo) + { + string contentType = string.Format(CultureInfo.InvariantCulture, "{0};{1}={2}", MtomGlobals.XopType, MtomGlobals.CharsetParam, CharSet(encoding)); + + if (startInfo != null) + contentType = string.Format(CultureInfo.InvariantCulture, "{0};{1}=\"{2}\"", contentType, MtomGlobals.TypeParam, startInfo); + + return contentType; + } + + private static string CharSet(Encoding enc) + { + string name = enc.WebName; + if (string.Compare(name, Encoding.UTF8.WebName, StringComparison.OrdinalIgnoreCase) == 0) + return name; + if (string.Compare(name, Encoding.Unicode.WebName, StringComparison.OrdinalIgnoreCase) == 0) + return "utf-16LE"; + if (string.Compare(name, Encoding.BigEndianUnicode.WebName, StringComparison.OrdinalIgnoreCase) == 0) + return "utf-16BE"; + return name; + } + + public override void WriteStartElement(string prefix, string localName, string ns) + { + WriteBase64InlineIfPresent(); + ThrowIfElementIsXOPInclude(prefix, localName, ns); + Writer.WriteStartElement(prefix, localName, ns); + _depth++; + } + + public override async Task WriteStartElementAsync(string prefix, string localName, string ns) + { + await WriteBase64InlineIfPresentAsync(); + ThrowIfElementIsXOPInclude(prefix, localName, ns); + await Writer.WriteStartElementAsync(prefix, localName, ns); + _depth++; + } + + public override void WriteStartElement(string prefix, XmlDictionaryString localName, XmlDictionaryString ns) + { + if (localName == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(localName)); + + WriteBase64InlineIfPresent(); + ThrowIfElementIsXOPInclude(prefix, localName.Value, ns == null ? null : ns.Value); + Writer.WriteStartElement(prefix, localName, ns); + _depth++; + } + + private void ThrowIfElementIsXOPInclude(string prefix, string localName, string ns) + { + if (ns == null) + { + // This check isn't as thorough as on .NET Framework due to use of internal api's. + // The scenario that this won't catch is when the XopIncludeNamespace has been added + // multiple times with different prefixes. I don't believe that will be the case as + // any attempt to add it with a different prefix would hit this code path anyway. + var xopPrefix = Writer.LookupPrefix(MtomGlobals.XopIncludeNamespace); + if (xopPrefix != null && xopPrefix == prefix) + ns = MtomGlobals.XopIncludeNamespace; + } + + if (localName == MtomGlobals.XopIncludeLocalName && ns == MtomGlobals.XopIncludeNamespace) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MtomDataMustNotContainXopInclude, MtomGlobals.XopIncludeLocalName, MtomGlobals.XopIncludeNamespace))); + } + + public override void WriteEndElement() + { + WriteXOPInclude(); + Writer.WriteEndElement(); + _depth--; + WriteXOPBinaryParts(); + } + + public override async Task WriteEndElementAsync() + { + await WriteXOPIncludeAsync(); + await Writer.WriteEndElementAsync(); + _depth--; + await WriteXOPBinaryPartsAsync(); + } + + public override void WriteFullEndElement() + { + WriteXOPInclude(); + Writer.WriteFullEndElement(); + _depth--; + WriteXOPBinaryParts(); + } + + public override void WriteValue(IStreamProvider value) + { + if (value == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("value")); + + if (Writer.WriteState == WriteState.Element) + { + if (_binaryDataChunks == null) + { + _binaryDataChunks = new List(); + _contentID = GenerateUriForMimePart((_mimeParts == null) ? 1 : _mimeParts.Count + 1); + } + _binaryDataChunks.Add(new MtomBinaryData(value)); + } + else + Writer.WriteValue(value); + } + + public override void WriteBase64(byte[] buffer, int index, int count) + { + if (Writer.WriteState == WriteState.Element) + { + if (buffer == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("buffer")); + + // Not checking upper bound because it will be caught by "count". This is what XmlTextWriter does. + if (index < 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(index), SR.ValueMustBeNonNegative)); + + if (count < 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative)); + if (count > buffer.Length - index) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, buffer.Length - index))); + + if (_binaryDataChunks == null) + { + _binaryDataChunks = new List(); + _contentID = GenerateUriForMimePart((_mimeParts == null) ? 1 : _mimeParts.Count + 1); + } + + int totalSize = ValidateSizeOfMessage(_maxSizeInBytes, 0, _totalSizeOfMimeParts); + totalSize += ValidateSizeOfMessage(_maxSizeInBytes, totalSize, _sizeOfBufferedBinaryData); + totalSize += ValidateSizeOfMessage(_maxSizeInBytes, totalSize, count); + _sizeOfBufferedBinaryData += count; + _binaryDataChunks.Add(new MtomBinaryData(buffer, index, count)); + } + else + Writer.WriteBase64(buffer, index, count); + } + + internal static int ValidateSizeOfMessage(int maxSize, int offset, int size) + { + if (size > (maxSize - offset)) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.MtomExceededMaxSizeInBytes, maxSize))); + return size; + } + + private void WriteBase64InlineIfPresent() + { + if (_binaryDataChunks != null) + { + WriteBase64Inline(); + } + } + + private Task WriteBase64InlineIfPresentAsync() + { + if (_binaryDataChunks != null) + { + return WriteBase64InlineAsync(); + } + else + { + return Task.CompletedTask; + } + } + + private void WriteBase64Inline() + { + foreach (MtomBinaryData data in _binaryDataChunks) + { + if (data.type == MtomBinaryDataType.Provider) + { + Writer.WriteValue(data.provider); + } + else + { + Writer.WriteBase64(data.chunk, 0, data.chunk.Length); + } + } + _sizeOfBufferedBinaryData = 0; + _binaryDataChunks = null; + _contentType = null; + _contentID = null; + } + + private async Task WriteBase64InlineAsync() + { + foreach (MtomBinaryData data in _binaryDataChunks) + { + if (data.type == MtomBinaryDataType.Provider) + { + await Writer.WriteValueAsync(data.provider); + } + else + { + await Writer.WriteBase64Async(data.chunk, 0, data.chunk.Length); + } + } + _sizeOfBufferedBinaryData = 0; + _binaryDataChunks = null; + _contentType = null; + _contentID = null; + } + + private void WriteXOPInclude() + { + if (_binaryDataChunks == null) + return; + + bool inline = true; + long size = 0; + foreach (MtomBinaryData data in _binaryDataChunks) + { + long len = data.Length; + if (len < 0 || len > (MaxInlinedBytes - size)) + { + inline = false; + break; + } + size += len; + } + + if (inline) + WriteBase64Inline(); + else + { + if (_mimeParts == null) + _mimeParts = new List(); + + MimePart mimePart = new MimePart(_binaryDataChunks, _contentID, _contentType, MimeGlobals.EncodingBinary, _sizeOfBufferedBinaryData, _maxSizeInBytes); + _mimeParts.Add(mimePart); + + _totalSizeOfMimeParts += ValidateSizeOfMessage(_maxSizeInBytes, _totalSizeOfMimeParts, mimePart.sizeInBytes); + _totalSizeOfMimeParts += ValidateSizeOfMessage(_maxSizeInBytes, _totalSizeOfMimeParts, _mimeWriter.GetBoundarySize()); + + Writer.WriteStartElement(MtomGlobals.XopIncludePrefix, MtomGlobals.XopIncludeLocalName, MtomGlobals.XopIncludeNamespace); + Writer.WriteStartAttribute(MtomGlobals.XopIncludeHrefLocalName, MtomGlobals.XopIncludeHrefNamespace); + Writer.WriteValue(string.Format(CultureInfo.InvariantCulture, "{0}{1}", MimeGlobals.ContentIDScheme, _contentID)); + Writer.WriteEndAttribute(); + Writer.WriteEndElement(); + _binaryDataChunks = null; + _sizeOfBufferedBinaryData = 0; + _contentType = null; + _contentID = null; + } + } + + private async Task WriteXOPIncludeAsync() + { + if (_binaryDataChunks == null) + return; + + bool inline = true; + long size = 0; + foreach (MtomBinaryData data in _binaryDataChunks) + { + long len = data.Length; + if (len < 0 || len > (MaxInlinedBytes - size)) + { + inline = false; + break; + } + size += len; + } + + if (inline) + await WriteBase64InlineAsync(); + else + { + if (_mimeParts == null) + _mimeParts = new List(); + + MimePart mimePart = new MimePart(_binaryDataChunks, _contentID, _contentType, MimeGlobals.EncodingBinary, _sizeOfBufferedBinaryData, _maxSizeInBytes); + _mimeParts.Add(mimePart); + + _totalSizeOfMimeParts += ValidateSizeOfMessage(_maxSizeInBytes, _totalSizeOfMimeParts, mimePart.sizeInBytes); + _totalSizeOfMimeParts += ValidateSizeOfMessage(_maxSizeInBytes, _totalSizeOfMimeParts, _mimeWriter.GetBoundarySize()); + + await Writer.WriteStartElementAsync(MtomGlobals.XopIncludePrefix, MtomGlobals.XopIncludeLocalName, MtomGlobals.XopIncludeNamespace); + Writer.WriteStartAttribute(MtomGlobals.XopIncludeHrefLocalName, MtomGlobals.XopIncludeHrefNamespace); + Writer.WriteString(string.Format(CultureInfo.InvariantCulture, "{0}{1}", MimeGlobals.ContentIDScheme, _contentID)); + Writer.WriteEndAttribute(); + await Writer.WriteEndElementAsync(); + _binaryDataChunks = null; + _sizeOfBufferedBinaryData = 0; + _contentType = null; + _contentID = null; + } + } + + public static string GenerateUriForMimePart(int index) + { + return string.Format(CultureInfo.InvariantCulture, "http://tempuri.org/{0}/{1}", index, DateTime.Now.Ticks); + } + + private void WriteXOPBinaryParts() + { + if (_depth > 0 || _mimeWriter.WriteState == MimeWriterState.Closed) + return; + + if (Writer.WriteState != WriteState.Closed) + Writer.Flush(); + + if (_mimeParts != null) + { + foreach (MimePart part in _mimeParts) + { + WriteMimeHeaders(part.contentID, part.contentType, part.contentTransferEncoding); + Stream s = _mimeWriter.GetContentStream(); + int blockSize = 256; + int bytesRead = 0; + byte[] block = new byte[blockSize]; + Stream stream = null; + foreach (MtomBinaryData data in part.binaryData) + { + if (data.type == MtomBinaryDataType.Provider) + { + stream = data.provider.GetStream(); + if (stream == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.XmlInvalidStream)); + while (true) + { + bytesRead = stream.Read(block, 0, blockSize); + if (bytesRead > 0) + s.Write(block, 0, bytesRead); + else + break; + if (blockSize < 65536 && bytesRead == blockSize) + { + blockSize = blockSize * 16; + block = new byte[blockSize]; + } + } + + data.provider.ReleaseStream(stream); + } + else + { + s.Write(data.chunk, 0, data.chunk.Length); + } + } + } + _mimeParts.Clear(); + } + _mimeWriter.Close(); + } + + private async Task WriteXOPBinaryPartsAsync() + { + if (_depth > 0 || _mimeWriter.WriteState == MimeWriterState.Closed) + return; + + if (Writer.WriteState != WriteState.Closed) + await Writer.FlushAsync(); + + if (_mimeParts != null) + { + foreach (MimePart part in _mimeParts) + { + await WriteMimeHeadersAsync(part.contentID, part.contentType, part.contentTransferEncoding); + Stream s = await _mimeWriter.GetContentStreamAsync(); + int blockSize = 256; + int bytesRead = 0; + byte[] block = new byte[blockSize]; + Stream stream = null; + foreach (MtomBinaryData data in part.binaryData) + { + if (data.type == MtomBinaryDataType.Provider) + { + stream = data.provider.GetStream(); + if (stream == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.XmlInvalidStream)); + while (true) + { + bytesRead = stream.Read(block, 0, blockSize); + if (bytesRead > 0) + s.Write(block, 0, bytesRead); + else + break; + if (blockSize < 65536 && bytesRead == blockSize) + { + blockSize = blockSize * 16; + block = new byte[blockSize]; + } + } + + data.provider.ReleaseStream(stream); + } + else + { + s.Write(data.chunk, 0, data.chunk.Length); + } + } + } + _mimeParts.Clear(); + } + await _mimeWriter.CloseAsync(); + } + + private void WriteMimeHeaders(string contentID, string contentType, string contentTransferEncoding) + { + _mimeWriter.StartPart(); + if (contentID != null) + _mimeWriter.WriteHeader(MimeGlobals.ContentIDHeader, string.Format(CultureInfo.InvariantCulture, "<{0}>", contentID)); + if (contentTransferEncoding != null) + _mimeWriter.WriteHeader(MimeGlobals.ContentTransferEncodingHeader, contentTransferEncoding); + if (contentType != null) + _mimeWriter.WriteHeader(MimeGlobals.ContentTypeHeader, contentType); + } + + private async Task WriteMimeHeadersAsync(string contentID, string contentType, string contentTransferEncoding) + { + await _mimeWriter.StartPartAsync(); + if (contentID != null) + _mimeWriter.WriteHeader(MimeGlobals.ContentIDHeader, string.Format(CultureInfo.InvariantCulture, "<{0}>", contentID)); + if (contentTransferEncoding != null) + _mimeWriter.WriteHeader(MimeGlobals.ContentTransferEncodingHeader, contentTransferEncoding); + if (contentType != null) + _mimeWriter.WriteHeader(MimeGlobals.ContentTypeHeader, contentType); + } +#if NO + public override bool CanSubsetElements + { + get { return Writer.CanSubsetElements; } + } +#endif + public override void Close() + { + if (!_isClosed) + { + _isClosed = true; + if (IsInitialized) + { + WriteXOPInclude(); + if (Writer.WriteState == WriteState.Element || + Writer.WriteState == WriteState.Attribute || + Writer.WriteState == WriteState.Content) + { + Writer.WriteEndDocument(); + } + Writer.Flush(); + _depth = 0; + WriteXOPBinaryParts(); + Writer.Close(); + } + } + } + + private void CheckIfStartContentTypeAttribute(string localName, string ns) + { + if (localName != null && localName == MtomGlobals.MimeContentTypeLocalName + && ns != null && (ns == MtomGlobals.MimeContentTypeNamespace200406 || ns == MtomGlobals.MimeContentTypeNamespace200505)) + { + _contentTypeStream = new MemoryStream(); + this._infosetWriter = Writer; + _writer = XmlDictionaryWriter.CreateBinaryWriter(_contentTypeStream); + Writer.WriteStartElement("Wrapper"); + Writer.WriteStartAttribute(localName, ns); + } + } + + private void CheckIfEndContentTypeAttribute() + { + if (_contentTypeStream != null) + { + Writer.WriteEndAttribute(); + Writer.WriteEndElement(); + Writer.Flush(); + _contentTypeStream.Position = 0; + XmlReader contentTypeReader = XmlDictionaryReader.CreateBinaryReader(_contentTypeStream, null, XmlDictionaryReaderQuotas.Max, null, null); + while (contentTypeReader.Read()) + { + if (contentTypeReader.IsStartElement("Wrapper")) + { + _contentType = contentTypeReader.GetAttribute(MtomGlobals.MimeContentTypeLocalName, MtomGlobals.MimeContentTypeNamespace200406); + if (_contentType == null) + { + _contentType = contentTypeReader.GetAttribute(MtomGlobals.MimeContentTypeLocalName, MtomGlobals.MimeContentTypeNamespace200505); + } + break; + } + } + _writer = _infosetWriter; + this._infosetWriter = null; + _contentTypeStream = null; + if (_contentType != null) + Writer.WriteString(_contentType); + } + } + +#if NO + public override bool ElementSubsetting + { + get + { + return Writer.ElementSubsetting; + } + set + { + Writer.ElementSubsetting = value; + } + } +#endif + public override void Flush() + { + if (IsInitialized) + Writer.Flush(); + } + + public override Task FlushAsync() + { + if (IsInitialized) + return Writer.FlushAsync(); + else + return Task.CompletedTask; + } + + public override string LookupPrefix(string ns) + { + return Writer.LookupPrefix(ns); + } + + public override XmlWriterSettings Settings + { + get + { + return Writer.Settings; + } + } + + public override void WriteAttributes(XmlReader reader, bool defattr) + { + Writer.WriteAttributes(reader, defattr); + } + + public override void WriteBinHex(byte[] buffer, int index, int count) + { + WriteBase64InlineIfPresent(); + Writer.WriteBinHex(buffer, index, count); + } + + public override void WriteCData(string text) + { + WriteBase64InlineIfPresent(); + Writer.WriteCData(text); + } + + public override void WriteCharEntity(char ch) + { + WriteBase64InlineIfPresent(); + Writer.WriteCharEntity(ch); + } + + public override void WriteChars(char[] buffer, int index, int count) + { + WriteBase64InlineIfPresent(); + Writer.WriteChars(buffer, index, count); + } + + public override void WriteComment(string text) + { + // Don't write comments after the document element + if (_depth == 0 && _mimeWriter.WriteState == MimeWriterState.Closed) + return; + + WriteBase64InlineIfPresent(); + Writer.WriteComment(text); + } + + public override void WriteDocType(string name, string pubid, string sysid, string subset) + { + WriteBase64InlineIfPresent(); + Writer.WriteDocType(name, pubid, sysid, subset); + } +#if NO + public override void WriteElementSubset(ArraySegment buffer) + { + Writer.WriteElementSubset(buffer); + } +#endif + public override void WriteEndAttribute() + { + CheckIfEndContentTypeAttribute(); + Writer.WriteEndAttribute(); + } + + public override void WriteEndDocument() + { + WriteXOPInclude(); + Writer.WriteEndDocument(); + _depth = 0; + WriteXOPBinaryParts(); + } + + public override void WriteEntityRef(string name) + { + WriteBase64InlineIfPresent(); + Writer.WriteEntityRef(name); + } + + public override void WriteName(string name) + { + WriteBase64InlineIfPresent(); + Writer.WriteName(name); + } + + public override void WriteNmToken(string name) + { + WriteBase64InlineIfPresent(); + Writer.WriteNmToken(name); + } + + protected override void WriteTextNode(XmlDictionaryReader reader, bool attribute) + { + Type type = reader.ValueType; + if (type == typeof(string)) + { + if (reader.CanReadValueChunk) + { + if (_chars == null) + { + _chars = new char[256]; + } + int count; + while ((count = reader.ReadValueChunk(_chars, 0, _chars.Length)) > 0) + { + WriteChars(_chars, 0, count); + } + } + else + { + WriteString(reader.Value); + } + if (!attribute) + { + reader.Read(); + } + } + else if (type == typeof(byte[])) + { + if (reader.CanReadBinaryContent) + { + // Its best to read in buffers that are a multiple of 3 so we don't break base64 boundaries when converting text + if (_bytes == null) + { + _bytes = new byte[384]; + } + int count; + while ((count = reader.ReadValueAsBase64(_bytes, 0, _bytes.Length)) > 0) + { + WriteBase64(_bytes, 0, count); + } + } + else + { + WriteString(reader.Value); + } + if (!attribute) + { + reader.Read(); + } + } + else + { + base.WriteTextNode(reader, attribute); + } + } + + public override void WriteNode(XPathNavigator navigator, bool defattr) + { + WriteBase64InlineIfPresent(); + Writer.WriteNode(navigator, defattr); + } + + public override void WriteProcessingInstruction(string name, string text) + { + WriteBase64InlineIfPresent(); + Writer.WriteProcessingInstruction(name, text); + } + + public override void WriteQualifiedName(string localName, string namespaceUri) + { + WriteBase64InlineIfPresent(); + Writer.WriteQualifiedName(localName, namespaceUri); + } + + public override void WriteRaw(char[] buffer, int index, int count) + { + WriteBase64InlineIfPresent(); + Writer.WriteRaw(buffer, index, count); + } + + public override void WriteRaw(string data) + { + WriteBase64InlineIfPresent(); + Writer.WriteRaw(data); + } + + public override void WriteStartAttribute(string prefix, string localName, string ns) + { + Writer.WriteStartAttribute(prefix, localName, ns); + CheckIfStartContentTypeAttribute(localName, ns); + } + + public override void WriteStartAttribute(string prefix, XmlDictionaryString localName, XmlDictionaryString ns) + { + Writer.WriteStartAttribute(prefix, localName, ns); + if (localName != null && ns != null) + CheckIfStartContentTypeAttribute(localName.Value, ns.Value); + } + + public override void WriteStartDocument() + { + Writer.WriteStartDocument(); + } + + public override void WriteStartDocument(bool standalone) + { + Writer.WriteStartDocument(standalone); + } + + public override WriteState WriteState + { + get + { + return Writer.WriteState; + } + } + + public override void WriteString(string text) + { + // Don't write whitespace after the document element + if (_depth == 0 && _mimeWriter.WriteState == MimeWriterState.Closed && XmlConverter.IsWhitespace(text)) + return; + + WriteBase64InlineIfPresent(); + Writer.WriteString(text); + } + + public override void WriteString(XmlDictionaryString value) + { + // Don't write whitespace after the document element + if (_depth == 0 && _mimeWriter.WriteState == MimeWriterState.Closed && XmlConverter.IsWhitespace(value.Value)) + return; + + WriteBase64InlineIfPresent(); + Writer.WriteString(value); + } + + public override void WriteSurrogateCharEntity(char lowChar, char highChar) + { + WriteBase64InlineIfPresent(); + Writer.WriteSurrogateCharEntity(lowChar, highChar); + } + + public override void WriteWhitespace(string whitespace) + { + // Don't write whitespace after the document element + if (_depth == 0 && _mimeWriter.WriteState == MimeWriterState.Closed) + return; + + WriteBase64InlineIfPresent(); + Writer.WriteWhitespace(whitespace); + } + + public override void WriteValue(object value) + { + IStreamProvider sp = value as IStreamProvider; + if (sp != null) + { + WriteValue(sp); + } + else + { + WriteBase64InlineIfPresent(); + Writer.WriteValue(value); + } + } + + public override void WriteValue(string value) + { + // Don't write whitespace after the document element + if (_depth == 0 && _mimeWriter.WriteState == MimeWriterState.Closed && XmlConverter.IsWhitespace(value)) + return; + + WriteBase64InlineIfPresent(); + Writer.WriteValue(value); + } + + public override void WriteValue(bool value) + { + WriteBase64InlineIfPresent(); + Writer.WriteValue(value); + } + + public override void WriteValue(DateTime value) + { + WriteBase64InlineIfPresent(); + Writer.WriteValue(value); + } + + public override void WriteValue(double value) + { + WriteBase64InlineIfPresent(); + Writer.WriteValue(value); + } + + public override void WriteValue(int value) + { + WriteBase64InlineIfPresent(); + Writer.WriteValue(value); + } + + public override void WriteValue(long value) + { + WriteBase64InlineIfPresent(); + Writer.WriteValue(value); + } + +#if DECIMAL_FLOAT_API + public override void WriteValue(decimal value) + { + WriteBase64InlineIfPresent(); + Writer.WriteValue(value); + } + + public override void WriteValue(float value) + { + WriteBase64InlineIfPresent(); + Writer.WriteValue(value); + } +#endif + public override void WriteValue(XmlDictionaryString value) + { + // Don't write whitespace after the document element + if (_depth == 0 && _mimeWriter.WriteState == MimeWriterState.Closed && XmlConverter.IsWhitespace(value.Value)) + return; + + WriteBase64InlineIfPresent(); + Writer.WriteValue(value); + } + + public override void WriteXmlnsAttribute(string prefix, string ns) + { + Writer.WriteXmlnsAttribute(prefix, ns); + } + + public override void WriteXmlnsAttribute(string prefix, XmlDictionaryString ns) + { + Writer.WriteXmlnsAttribute(prefix, ns); + } + + public override string XmlLang + { + get + { + return Writer.XmlLang; + } + } + + public override XmlSpace XmlSpace + { + get + { + return Writer.XmlSpace; + } + } + + private static class MimeBoundaryGenerator + { + private static long id; + private static string prefix; + + static MimeBoundaryGenerator() + { + prefix = string.Concat(Guid.NewGuid().ToString(), "+id="); + } + + internal static string Next() + { + long nextId = Interlocked.Increment(ref id); + return string.Format(CultureInfo.InvariantCulture, "{0}{1}", prefix, nextId); + } + } + + private class MimePart + { + internal IList binaryData; + internal string contentID; + internal string contentType; + internal string contentTransferEncoding; + internal int sizeInBytes; + + internal MimePart(IList binaryData, string contentID, string contentType, string contentTransferEncoding, int sizeOfBufferedBinaryData, int maxSizeInBytes) + { + this.binaryData = binaryData; + this.contentID = contentID; + this.contentType = contentType ?? MtomGlobals.DefaultContentTypeForBinary; + this.contentTransferEncoding = contentTransferEncoding; + sizeInBytes = GetSize(contentID, contentType, contentTransferEncoding, sizeOfBufferedBinaryData, maxSizeInBytes); + } + + private static int GetSize(string contentID, string contentType, string contentTransferEncoding, int sizeOfBufferedBinaryData, int maxSizeInBytes) + { + int size = XmlMtomWriter.ValidateSizeOfMessage(maxSizeInBytes, 0, MimeGlobals.CRLF.Length * 3); + if (contentTransferEncoding != null) + size += XmlMtomWriter.ValidateSizeOfMessage(maxSizeInBytes, size, MimeWriter.GetHeaderSize(MimeGlobals.ContentTransferEncodingHeader, contentTransferEncoding, maxSizeInBytes)); + if (contentType != null) + size += XmlMtomWriter.ValidateSizeOfMessage(maxSizeInBytes, size, MimeWriter.GetHeaderSize(MimeGlobals.ContentTypeHeader, contentType, maxSizeInBytes)); + if (contentID != null) + { + size += XmlMtomWriter.ValidateSizeOfMessage(maxSizeInBytes, size, MimeWriter.GetHeaderSize(MimeGlobals.ContentIDHeader, contentID, maxSizeInBytes)); + size += XmlMtomWriter.ValidateSizeOfMessage(maxSizeInBytes, size, 2); // include '<' and '>' + } + size += XmlMtomWriter.ValidateSizeOfMessage(maxSizeInBytes, size, sizeOfBufferedBinaryData); + return size; + } + } + } + + + internal static class MtomGlobals + { + internal static string XopIncludeLocalName = "Include"; + internal static string XopIncludeNamespace = "http://www.w3.org/2004/08/xop/include"; + internal static string XopIncludePrefix = "xop"; + internal static string XopIncludeHrefLocalName = "href"; + internal static string XopIncludeHrefNamespace = string.Empty; + internal static string MediaType = "multipart"; + internal static string MediaSubtype = "related"; + internal static string BoundaryParam = "boundary"; + internal static string TypeParam = "type"; + internal static string XopMediaType = "application"; + internal static string XopMediaSubtype = "xop+xml"; + internal static string XopType = "application/xop+xml"; + internal static string StartParam = "start"; + internal static string StartInfoParam = "start-info"; + internal static string ActionParam = "action"; + internal static string CharsetParam = "charset"; + internal static string MimeContentTypeLocalName = "contentType"; + internal static string MimeContentTypeNamespace200406 = "http://www.w3.org/2004/06/xmlmime"; + internal static string MimeContentTypeNamespace200505 = "http://www.w3.org/2005/05/xmlmime"; + internal static string DefaultContentTypeForBinary = "application/octet-stream"; + } + + internal static class MimeGlobals + { + internal static string MimeVersionHeader = "MIME-Version"; + internal static string DefaultVersion = "1.0"; + internal static string ContentIDScheme = "cid:"; + internal static string ContentIDHeader = "Content-ID"; + internal static string ContentTypeHeader = "Content-Type"; + internal static string ContentTransferEncodingHeader = "Content-Transfer-Encoding"; + internal static string EncodingBinary = "binary"; + internal static string Encoding8bit = "8bit"; + internal static byte[] COLONSPACE = new byte[] { (byte)':', (byte)' ' }; + internal static byte[] DASHDASH = new byte[] { (byte)'-', (byte)'-' }; + internal static byte[] CRLF = new byte[] { (byte)'\r', (byte)'\n' }; + // Per RFC2045, preceding CRLF sequence is part of the boundary. MIME boundary tags begin with -- + internal static byte[] BoundaryPrefix = new byte[] { (byte)'\r', (byte)'\n', (byte)'-', (byte)'-' }; + } + + internal enum MimeWriterState + { + Start, + StartPreface, + StartPart, + Header, + Content, + Closed, + } + + internal class MimeWriter + { + private Stream stream; + private byte[] boundaryBytes; + private MimeWriterState state; + private BufferedWrite bufferedWrite; + private Stream contentStream; + + internal MimeWriter(Stream stream, string boundary) + { + if (stream == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(stream)); + if (boundary == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(boundary)); + + this.stream = stream; + boundaryBytes = MimeWriter.GetBoundaryBytes(boundary); + state = MimeWriterState.Start; + bufferedWrite = new BufferedWrite(); + } + + internal static int GetHeaderSize(string name, string value, int maxSizeInBytes) + { + if (name == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(name)); + if (value == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value)); + + int size = XmlMtomWriter.ValidateSizeOfMessage(maxSizeInBytes, 0, MimeGlobals.COLONSPACE.Length + MimeGlobals.CRLF.Length); + size += XmlMtomWriter.ValidateSizeOfMessage(maxSizeInBytes, size, name.Length); + size += XmlMtomWriter.ValidateSizeOfMessage(maxSizeInBytes, size, value.Length); + return size; + } + + internal static byte[] GetBoundaryBytes(string boundary) + { + byte[] boundaryBytes = new byte[boundary.Length + MimeGlobals.BoundaryPrefix.Length]; + for (int i = 0; i < MimeGlobals.BoundaryPrefix.Length; i++) + boundaryBytes[i] = MimeGlobals.BoundaryPrefix[i]; + Encoding.ASCII.GetBytes(boundary, 0, boundary.Length, boundaryBytes, MimeGlobals.BoundaryPrefix.Length); + return boundaryBytes; + } + + internal MimeWriterState WriteState + { + get + { + return state; + } + } + + internal int GetBoundarySize() + { + return boundaryBytes.Length; + } + + internal void StartPreface() + { + if (state != MimeWriterState.Start) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.MimeWriterInvalidStateForStartPreface, state.ToString()))); + + state = MimeWriterState.StartPreface; + } + + internal async Task StartPartAsync() + { + switch (state) + { + case MimeWriterState.StartPart: + case MimeWriterState.Closed: + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.MimeWriterInvalidStateForStartPart, state.ToString()))); + default: + break; + } + + state = MimeWriterState.StartPart; + + if (contentStream != null) + { + await contentStream.FlushAsync(); + contentStream = null; + } + + bufferedWrite.Write(boundaryBytes); + bufferedWrite.Write(MimeGlobals.CRLF); + } + + internal void StartPart() + { + switch (state) + { + case MimeWriterState.StartPart: + case MimeWriterState.Closed: + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.MimeWriterInvalidStateForStartPart, state.ToString()))); + default: + break; + } + + state = MimeWriterState.StartPart; + + if (contentStream != null) + { + contentStream.Flush(); + contentStream = null; + } + + bufferedWrite.Write(boundaryBytes); + bufferedWrite.Write(MimeGlobals.CRLF); + } + + internal void Close() + { + switch (state) + { + case MimeWriterState.Closed: + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.MimeWriterInvalidStateForClose, state.ToString()))); + default: + break; + } + + state = MimeWriterState.Closed; + + if (contentStream != null) + { + contentStream.Flush(); + contentStream = null; + } + + bufferedWrite.Write(boundaryBytes); + bufferedWrite.Write(MimeGlobals.DASHDASH); + bufferedWrite.Write(MimeGlobals.CRLF); + + Flush(); + } + + internal async Task CloseAsync() + { + switch (state) + { + case MimeWriterState.Closed: + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.MimeWriterInvalidStateForClose, state.ToString()))); + default: + break; + } + + state = MimeWriterState.Closed; + + if (contentStream != null) + { + await contentStream.FlushAsync(); + contentStream = null; + } + + bufferedWrite.Write(boundaryBytes); + bufferedWrite.Write(MimeGlobals.DASHDASH); + bufferedWrite.Write(MimeGlobals.CRLF); + + await FlushAsync(); + } + + private async Task FlushAsync() + { + if (bufferedWrite.Length > 0) + { + await stream.WriteAsync(bufferedWrite.GetBuffer(), 0, bufferedWrite.Length); + bufferedWrite.Reset(); + } + } + + private void Flush() + { + if (bufferedWrite.Length > 0) + { + stream.Write(bufferedWrite.GetBuffer(), 0, bufferedWrite.Length); + bufferedWrite.Reset(); + } + } + + internal void WriteHeader(string name, string value) + { + if (name == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(name)); + if (value == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value)); + + switch (state) + { + case MimeWriterState.Start: + case MimeWriterState.Content: + case MimeWriterState.Closed: + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.MimeWriterInvalidStateForHeader, state.ToString()))); + default: + break; + } + + state = MimeWriterState.Header; + + bufferedWrite.Write(name); + bufferedWrite.Write(MimeGlobals.COLONSPACE); + bufferedWrite.Write(value); + bufferedWrite.Write(MimeGlobals.CRLF); + } + + internal async Task GetContentStreamAsync() + { + switch (state) + { + case MimeWriterState.Start: + case MimeWriterState.Content: + case MimeWriterState.Closed: + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.MimeWriterInvalidStateForContent, state.ToString()))); + default: + break; + } + + state = MimeWriterState.Content; + bufferedWrite.Write(MimeGlobals.CRLF); + await FlushAsync(); + contentStream = stream; + return contentStream; + } + + internal Stream GetContentStream() + { + switch (state) + { + case MimeWriterState.Start: + case MimeWriterState.Content: + case MimeWriterState.Closed: + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.MimeWriterInvalidStateForContent, state.ToString()))); + default: + break; + } + + state = MimeWriterState.Content; + bufferedWrite.Write(MimeGlobals.CRLF); + Flush(); + contentStream = stream; + return contentStream; + } + } + + internal class BufferedWrite + { + private byte[] buffer; + private int offset; + + internal BufferedWrite() + : this(256) + { + } + + internal BufferedWrite(int initialSize) + { + buffer = new byte[initialSize]; + } + + private void EnsureBuffer(int count) + { + int currSize = buffer.Length; + if (count > currSize - offset) + { + int newSize = currSize; + do + { + if (newSize == int.MaxValue) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.WriteBufferOverflow)); + newSize = (newSize < int.MaxValue / 2) ? newSize * 2 : int.MaxValue; + } + while (count > newSize - offset); + byte[] newBuffer = new byte[newSize]; + Buffer.BlockCopy(buffer, 0, newBuffer, 0, offset); + buffer = newBuffer; + } + } + + internal int Length + { + get + { + return offset; + } + } + + internal byte[] GetBuffer() + { + return buffer; + } + + internal void Reset() + { + offset = 0; + } + + internal void Write(byte[] value) + { + Write(value, 0, value.Length); + } + + internal void Write(byte[] value, int index, int count) + { + EnsureBuffer(count); + Buffer.BlockCopy(value, index, buffer, offset, count); + offset += count; + } + + internal void Write(string value) + { + Write(value, 0, value.Length); + } + + internal void Write(string value, int index, int count) + { + EnsureBuffer(count); + for (int i = 0; i < count; i++) + { + char c = value[index + i]; + if ((ushort)c > 0xFF) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.Format(SR.MimeHeaderInvalidCharacter, c, ((int)c).ToString("X", CultureInfo.InvariantCulture)))); + buffer[offset + i] = (byte)c; + } + offset += count; + } + +#if NO + internal void Write(byte value) + { + EnsureBuffer(1); + buffer[offset++] = value; + } + + internal void Write(char value) + { + EnsureBuffer(1); + if ((ushort)value > 0xFF) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.Format(SR.MimeHeaderInvalidCharacter, value, ((int)value).ToString("X", CultureInfo.InvariantCulture))))); + buffer[offset++] = (byte)value; + } + + internal void Write(int value) + { + Write(value.ToString()); + } + + internal void Write(char[] value) + { + Write(value, 0, value.Length); + } + + internal void Write(char[] value, int index, int count) + { + EnsureBuffer(count); + for (int i = 0; i < count; i++) + { + char c = value[index + i]; + if ((ushort)c > 0xFF) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.Format(SR.MimeHeaderInvalidCharacter, c, ((int)c).ToString("X", CultureInfo.InvariantCulture))))); + buffer[offset + i] = (byte)c; + } + offset += count; + } + +#endif + + } + + internal enum MtomBinaryDataType { Provider, Segment } + + internal class MtomBinaryData + { + internal MtomBinaryDataType type; + + internal IStreamProvider provider; + internal byte[] chunk; + + internal MtomBinaryData(IStreamProvider provider) + { + type = MtomBinaryDataType.Provider; + this.provider = provider; + } + + internal MtomBinaryData(byte[] buffer, int offset, int count) + { + type = MtomBinaryDataType.Segment; + chunk = new byte[count]; + Buffer.BlockCopy(buffer, offset, chunk, 0, count); + } + + internal long Length + { + get + { + if (type == MtomBinaryDataType.Segment) + return chunk.Length; + + return -1; + } + } + } +} diff --git a/src/System.Private.ServiceModel/src/Internals/WcfEventSource.cs b/src/System.Private.ServiceModel/src/Internals/WcfEventSource.cs index c681fcb928e..da1635a7289 100644 --- a/src/System.Private.ServiceModel/src/Internals/WcfEventSource.cs +++ b/src/System.Private.ServiceModel/src/Internals/WcfEventSource.cs @@ -1277,6 +1277,26 @@ public void BinaryMessageEncodingStart(EventTraceActivity eventTraceActivity) BinaryMessageEncodingStart(""); } + public bool MtomMessageEncodingStartIsEnabled() + { + return base.IsEnabled(EventLevel.Verbose, Keywords.Channel, EventChannel.Debug); + } + + [Event(EventIds.MtomMessageEncodingStart, Level = EventLevel.Verbose, Channel = EventChannel.Debug, Opcode = EventOpcode.Start, Task = Tasks.MessageEncoding, + Keywords = Keywords.Channel, + Message = "MtomMessageEncoder started encoding the message.")] + public void MtomMessageEncodingStart(string AppDomain) + { + WriteEvent(EventIds.MtomMessageEncodingStart, AppDomain); + } + + [NonEvent] + public void MtomMessageEncodingStart(EventTraceActivity eventTraceActivity) + { + SetActivityId(eventTraceActivity); + MtomMessageEncodingStart(""); + } + public bool TextMessageEncodingStartIsEnabled() { return base.IsEnabled(EventLevel.Verbose, Keywords.Channel, EventChannel.Debug); @@ -1314,6 +1334,25 @@ public void BinaryMessageDecodingStart() BinaryMessageDecodingStart(""); } + public bool MtomMessageDecodingStartIsEnabled() + { + return base.IsEnabled(EventLevel.Verbose, Keywords.Channel, EventChannel.Debug); + } + + [Event(EventIds.MtomMessageDecodingStart, Level = EventLevel.Verbose, Channel = EventChannel.Debug, Opcode = EventOpcode.Start, Task = Tasks.MessageDecoding, + Keywords = Keywords.Channel, + Message = "MtomMessageEncoder started decoding the message.")] + public void MtomMessageDecodingStart(string AppDomain) + { + WriteEvent(EventIds.MtomMessageDecodingStart, AppDomain); + } + + [NonEvent] + public void MtomMessageDecodingStart() + { + MtomMessageDecodingStart(""); + } + public bool TextMessageDecodingStartIsEnabled() { return base.IsEnabled(EventLevel.Verbose, Keywords.Channel, EventChannel.Debug); diff --git a/src/System.Private.ServiceModel/src/Resources/Strings.resx b/src/System.Private.ServiceModel/src/Resources/Strings.resx index db400c4be97..ce5e998937e 100644 --- a/src/System.Private.ServiceModel/src/Resources/Strings.resx +++ b/src/System.Private.ServiceModel/src/Resources/Strings.resx @@ -2822,8 +2822,173 @@ The endpoint identity specified when creating the HTTPS channel to '{0}' contains multiple server certificates. However, the HTTPS transport only supports the specification of a single server certificate. In order to create an HTTPS channel, please specify no more than one server certificate in the endpoint identity. - - + + Only HOST and HTTP service principal names are supported . - + + '{0}' not a valid MIME boundary. + + + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + + + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + + + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + + + contentType must be non-zero length string. + + + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + + + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + + + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + + + URI specified for MIME part Content-ID cannot be empty. + + + Invalid start URI for infoset '{0}'. + + + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + + + Content-Type header for MTOM message not found. + + + MTOM message not valid. Does not contain correctly formatted content following headers. + + + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + + + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + + + MTOM messages must have type '{0}'. + + + MTOM messages must have media type '{0}' and media subtype '{1}'. + + + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + + + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + + + MIME part with Content-ID '{0}' not found. + + + Content-Type header for root MIME part not found. + + + Root MIME part must have media type '{0}' and media subtype '{1}'. + + + Root MIME part containing infoset not found. + + + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + + + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + + + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + + + Mandatory attribute '{0}' not found on XOP Include element. + + + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + + + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + + + The characters '{0}' at offset {1} are not a valid BinHex sequence. + + + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + + + Array too small. + + + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + + + Line {0}, position {1}. + + + Invalid MIME content-type header encountered on read. + + + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + + + Content stream can be retrieved from MIME message only once. + + + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + + + '{0}' MIME header is specified multiple times. + + + Malformed header. + + + Reset called on MIME header reader before end of file. + + + Unexpected end of file. + + + Invalid mime-version header encountered on read. + + + Cannot call Close on MIME writer in state '{0}'. + + + MIME writer cannot write MIME header in state '{0}'. + + + MIME writer cannot write content in state '{0}'. + + + MIME writer cannot start new MIME part in state '{0}'. + + + MIME writer cannot start preface in '{0}' state. + + + Read not supported on stream '{0}'. + + + Seek not supported on stream '{0}'. + + + An internal error has occurred. Overflow on MIME writer buffer. + + + Write not supported on stream '{0}'. + + + The XmlWriter is closed. + + + MessageVersion '{0}' not supported by MTOM encoder. + + + Error creating a reader for the MTOM message + + \ No newline at end of file diff --git a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.cs.xlf b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.cs.xlf index fbf7405bc65..7681c254fba 100644 --- a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.cs.xlf +++ b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.cs.xlf @@ -1602,6 +1602,11 @@ Třída MaxBufferSize nesmí přesahovat třídu MaxReceivedMessageSize. + + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + + The maximum message size quota for incoming messages ({0}) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. Maximální kvóta velikosti zprávy pro příchozí zprávy ({0}) byla překročena. Chcete-li zvýšit kvótu, použijte vlastnost MaxReceivedMessageSize na příslušném elementu vazby. @@ -1762,6 +1767,71 @@ Došlo k potížím s formátem XML, který byl přijat ze sítě. Další informace naleznete v popisu vnitřní výjimky. + + Invalid MIME content-type header encountered on read. + Invalid MIME content-type header encountered on read. + + + + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + + + + Content stream can be retrieved from MIME message only once. + Content stream can be retrieved from MIME message only once. + + + + '{0}' MIME header is specified multiple times. + '{0}' MIME header is specified multiple times. + + + + Malformed header. + Malformed header. + + + + Reset called on MIME header reader before end of file. + Reset called on MIME header reader before end of file. + + + + Unexpected end of file. + Unexpected end of file. + + + + Invalid mime-version header encountered on read. + Invalid mime-version header encountered on read. + + + + Cannot call Close on MIME writer in state '{0}'. + Cannot call Close on MIME writer in state '{0}'. + + + + MIME writer cannot write content in state '{0}'. + MIME writer cannot write content in state '{0}'. + + + + MIME writer cannot write MIME header in state '{0}'. + MIME writer cannot write MIME header in state '{0}'. + + + + MIME writer cannot start new MIME part in state '{0}'. + MIME writer cannot start new MIME part in state '{0}'. + + + + MIME writer cannot start preface in '{0}' state. + MIME writer cannot start preface in '{0}' state. + + The incoming message was signed with a token which was different from what used to encrypt the body. This was not expected. Příchozí zpráva byla podepsána s tokenem, který se lišil od tokenu použitého k šifrování textu. Tato skutečnost nebyla očekávána. @@ -1817,6 +1887,156 @@ Přijatý token RequestSecurityTokenResponseCollection obsahuje více než jeden element RequestSecurityTokenResponse. Byl očekáván pouze jeden element RequestSecurityTokenResponse. + + '{0}' not a valid MIME boundary. + '{0}' not a valid MIME boundary. + + + + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + + + + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + + + + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + + + + contentType must be non-zero length string. + contentType must be non-zero length string. + + + + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + + + + MessageVersion '{0}' not supported by MTOM encoder. + MessageVersion '{0}' not supported by MTOM encoder. + + + + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + + + + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + + + + URI specified for MIME part Content-ID cannot be empty. + URI specified for MIME part Content-ID cannot be empty. + + + + Invalid start URI for infoset '{0}'. + Invalid start URI for infoset '{0}'. + + + + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + + + + Content-Type header for MTOM message not found. + Content-Type header for MTOM message not found. + + + + MTOM message not valid. Does not contain correctly formatted content following headers. + MTOM message not valid. Does not contain correctly formatted content following headers. + + + + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + + + + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + + + + MTOM messages must have type '{0}'. + MTOM messages must have type '{0}'. + + + + MTOM messages must have media type '{0}' and media subtype '{1}'. + MTOM messages must have media type '{0}' and media subtype '{1}'. + + + + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + + + + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + + + + MIME part with Content-ID '{0}' not found. + MIME part with Content-ID '{0}' not found. + + + + Content-Type header for root MIME part not found. + Content-Type header for root MIME part not found. + + + + Root MIME part must have media type '{0}' and media subtype '{1}'. + Root MIME part must have media type '{0}' and media subtype '{1}'. + + + + Root MIME part containing infoset not found. + Root MIME part containing infoset not found. + + + + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + + + + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + + + + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + + + + Mandatory attribute '{0}' not found on XOP Include element. + Mandatory attribute '{0}' not found on XOP Include element. + + + + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + + + + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + + The extensions cannot contain an Identity if one is supplied as a constructor argument. Rozšíření nesmějí obsahovat identitu, pokud je některá zadána jako argument konstruktoru. @@ -2157,6 +2377,11 @@ Algoritmus klíče pro tento veřejný klíč není podporován. + + Read not supported on stream '{0}'. + Read not supported on stream '{0}'. + + The channel received an unexpected fault input message while closing. The fault reason given is: '{0}' Během uzavírání přijal kanál neočekávanou zprávu vstupní chyby. Uvedený důvod chyby je: {0} @@ -2557,6 +2782,11 @@ Třídu EndpointDispatcher nelze přidat k více než jedné třídě ChannelDispatcher. + + Error creating a reader for the MTOM message + Error creating a reader for the MTOM message + + Server returned an invalid SOAP Fault. Please see InnerException for more details. Server vrátil neplatnou chybu SOAP. Další informace naleznete u třídy InnerException. @@ -3332,6 +3562,11 @@ Požadavek tokenu má pro vlastnost {1} neočekávaný typ {0}. Očekávaný typ vlastnosti je {2}. + + Seek not supported on stream '{0}'. + Seek not supported on stream '{0}'. + + You cannot Send messages on a channel after CloseOutputSession has been called. Nelze odesílat zprávy v kanálu po vyvolání třídy CloseOutputSession. @@ -4392,6 +4627,16 @@ Server nepřijal žádost o připojení. Verze protokolu WebSocket na straně klienta se pravděpodobně neshoduje s nastavením na straně serveru ({0}). + + An internal error has occurred. Overflow on MIME writer buffer. + An internal error has occurred. Overflow on MIME writer buffer. + + + + Write not supported on stream '{0}'. + Write not supported on stream '{0}'. + + The remote endpoint has sent an fault message with an unexpected sequence identifier over a session. The fault may be intended for a different session. The fault reason is: {0} The reliable session was faulted. Vzdálený koncový bod odeslal přes relaci chybovou zprávu s neočekávaným identifikátorem sekvence. Je možné, že je chyba určena pro jinou relaci. Důvod chyby je: {0} Ve stabilní relaci došlo k chybě. @@ -4462,6 +4707,11 @@ Nelze nalézt hodnotu {0} v řetězci slovníku. + + Array too small. + Array too small. + + An internal error has occurred. The XML buffer is not in the correct state to perform the operation. Došlo k vnitřní chybě. Vyrovnávací paměť XML není ve správném stavu k provedení operace. @@ -4472,6 +4722,16 @@ Velikost nutná k uložení obsahu XML do vyrovnávací paměti překročila její kvótu. + + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + + + + The characters '{0}' at offset {1} are not a valid BinHex sequence. + The characters '{0}' at offset {1} are not a valid BinHex sequence. + + The value '{0}' cannot be parsed as the type '{1}'. Hodnotu {0} nelze parsovat jako typ {1}. @@ -4487,6 +4747,21 @@ Chybí požadovaná hodnota atributu xml:lang. + + Line {0}, position {1}. + Line {0}, position {1}. + + + + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + + + + The XmlWriter is closed. + The XmlWriter is closed. + + '{0}' is an invalid XmlNodeType. {0} je neplatný typ XmlNodeType. diff --git a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.de.xlf b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.de.xlf index 24198b9bdca..e17e0f53ca0 100644 --- a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.de.xlf +++ b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.de.xlf @@ -1602,6 +1602,11 @@ MaxBufferSize darf MaxReceivedMessageSize nicht überschreiten. + + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + + The maximum message size quota for incoming messages ({0}) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. Das Kontingent für die maximale Nachrichtengröße für eingehende Nachrichten ({0}) wurde überschritten. Verwenden Sie die MaxReceivedMessageSize-Eigenschaft für das entsprechende Bindungselement, um das Kontingent zu erhöhen. @@ -1762,6 +1767,71 @@ Es ist ein Problem mit dem vom Netzwerk empfangenen XML aufgetreten. Weitere Informationen finden Sie in der inneren Ausnahme. + + Invalid MIME content-type header encountered on read. + Invalid MIME content-type header encountered on read. + + + + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + + + + Content stream can be retrieved from MIME message only once. + Content stream can be retrieved from MIME message only once. + + + + '{0}' MIME header is specified multiple times. + '{0}' MIME header is specified multiple times. + + + + Malformed header. + Malformed header. + + + + Reset called on MIME header reader before end of file. + Reset called on MIME header reader before end of file. + + + + Unexpected end of file. + Unexpected end of file. + + + + Invalid mime-version header encountered on read. + Invalid mime-version header encountered on read. + + + + Cannot call Close on MIME writer in state '{0}'. + Cannot call Close on MIME writer in state '{0}'. + + + + MIME writer cannot write content in state '{0}'. + MIME writer cannot write content in state '{0}'. + + + + MIME writer cannot write MIME header in state '{0}'. + MIME writer cannot write MIME header in state '{0}'. + + + + MIME writer cannot start new MIME part in state '{0}'. + MIME writer cannot start new MIME part in state '{0}'. + + + + MIME writer cannot start preface in '{0}' state. + MIME writer cannot start preface in '{0}' state. + + The incoming message was signed with a token which was different from what used to encrypt the body. This was not expected. Die eingehende Nachricht wurde mit einem Token signiert, das nicht mit dem Token identisch ist, das zum Verschlüsseln des Texts verwendet wurde. Dies wurde nicht erwartet. @@ -1817,6 +1887,156 @@ Die RequestSecurityTokenResponseCollection hat mehr als ein RequestSecurityTokenResponse-Element. Es wurde nur ein RequestSecurityTokenResponse-Element erwartet. + + '{0}' not a valid MIME boundary. + '{0}' not a valid MIME boundary. + + + + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + + + + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + + + + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + + + + contentType must be non-zero length string. + contentType must be non-zero length string. + + + + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + + + + MessageVersion '{0}' not supported by MTOM encoder. + MessageVersion '{0}' not supported by MTOM encoder. + + + + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + + + + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + + + + URI specified for MIME part Content-ID cannot be empty. + URI specified for MIME part Content-ID cannot be empty. + + + + Invalid start URI for infoset '{0}'. + Invalid start URI for infoset '{0}'. + + + + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + + + + Content-Type header for MTOM message not found. + Content-Type header for MTOM message not found. + + + + MTOM message not valid. Does not contain correctly formatted content following headers. + MTOM message not valid. Does not contain correctly formatted content following headers. + + + + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + + + + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + + + + MTOM messages must have type '{0}'. + MTOM messages must have type '{0}'. + + + + MTOM messages must have media type '{0}' and media subtype '{1}'. + MTOM messages must have media type '{0}' and media subtype '{1}'. + + + + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + + + + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + + + + MIME part with Content-ID '{0}' not found. + MIME part with Content-ID '{0}' not found. + + + + Content-Type header for root MIME part not found. + Content-Type header for root MIME part not found. + + + + Root MIME part must have media type '{0}' and media subtype '{1}'. + Root MIME part must have media type '{0}' and media subtype '{1}'. + + + + Root MIME part containing infoset not found. + Root MIME part containing infoset not found. + + + + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + + + + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + + + + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + + + + Mandatory attribute '{0}' not found on XOP Include element. + Mandatory attribute '{0}' not found on XOP Include element. + + + + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + + + + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + + The extensions cannot contain an Identity if one is supplied as a constructor argument. Die Erweiterungen dürfen keine Identität enthalten, wenn eine Identität als Konstruktorargument angegeben wird. @@ -2157,6 +2377,11 @@ Der Schlüsselalgorithmus für diesen öffentlichen Schlüssel wird nicht unterstützt. + + Read not supported on stream '{0}'. + Read not supported on stream '{0}'. + + The channel received an unexpected fault input message while closing. The fault reason given is: '{0}' Der Kanal hat beim Schließen eine unerwartete Fehlereingabenachricht empfangen. Angegebene Fehlerursache: "{0}" @@ -2557,6 +2782,11 @@ Der EndpointDispatcher kann maximal einem ChannelDispatcher hinzugefügt werden. + + Error creating a reader for the MTOM message + Error creating a reader for the MTOM message + + Server returned an invalid SOAP Fault. Please see InnerException for more details. Der Server hat einen ungültigen SOAP-Fehler zurückgegeben. Weitere Details finden Sie unter InnerException. @@ -3332,6 +3562,11 @@ Die Tokenanforderung enthält einen unerwarteten Typ "{1}" für die Eigenschaft "{0}". Erwartet wurde der Eigenschaftentyp "{2}" . + + Seek not supported on stream '{0}'. + Seek not supported on stream '{0}'. + + You cannot Send messages on a channel after CloseOutputSession has been called. Sie können keine Nachrichten über einen Kanal senden, nachdem CloseOutputSession aufgerufen wurde. @@ -4392,6 +4627,16 @@ Der Server hat die Verbindungsanforderung nicht akzeptiert. Möglicherweise stimmt die Version des WebSocket-Protokolls auf dem Client nicht mit der auf dem Server ("{0}") überein. + + An internal error has occurred. Overflow on MIME writer buffer. + An internal error has occurred. Overflow on MIME writer buffer. + + + + Write not supported on stream '{0}'. + Write not supported on stream '{0}'. + + The remote endpoint has sent an fault message with an unexpected sequence identifier over a session. The fault may be intended for a different session. The fault reason is: {0} The reliable session was faulted. Der Remoteendpunkt hat eine Fehlernachricht mit einem unerwarteten Sequenzbezeichner über eine Sitzung gesendet. Der Fehler bezog sich möglicherweise auf eine andere Sitzung. Fehlerursache: {0} Die zuverlässige Sitzung war nicht erfolgreich. @@ -4462,6 +4707,11 @@ Der Wert "{0}" wurde nicht in der Wörterbuchzeichenfolge gefunden. + + Array too small. + Array too small. + + An internal error has occurred. The XML buffer is not in the correct state to perform the operation. Ein interner Fehler ist aufgetreten. Der XML-Puffer befindet sich nicht im richtigen Zustand zum Ausführen des Vorgangs. @@ -4472,6 +4722,16 @@ Die erforderliche Größe zum Puffern der XML-Inhalte überschreitet das Pufferkontingent. + + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + + + + The characters '{0}' at offset {1} are not a valid BinHex sequence. + The characters '{0}' at offset {1} are not a valid BinHex sequence. + + The value '{0}' cannot be parsed as the type '{1}'. Der Wert "{0}" kann nicht als Typ "{1}" analysiert werden. @@ -4487,6 +4747,21 @@ Der erforderliche xml:lang-Attributwert fehlt. + + Line {0}, position {1}. + Line {0}, position {1}. + + + + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + + + + The XmlWriter is closed. + The XmlWriter is closed. + + '{0}' is an invalid XmlNodeType. "{0}" ist ein ungültiger XmlNodeType. diff --git a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.es.xlf b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.es.xlf index 13fec07f2f5..5dea2a43a99 100644 --- a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.es.xlf +++ b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.es.xlf @@ -1602,6 +1602,11 @@ MaxBufferSize no debe superar MaxReceivedMessageSize. + + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + + The maximum message size quota for incoming messages ({0}) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. Se ha excedido la cuota de tamaño máximo de los mensajes entrantes ({0}). Para aumentar la cuota, use la propiedad MaxReceivedMessageSize en el elemento de enlace correspondiente. @@ -1762,6 +1767,71 @@ Hay un problema con el XML que se recibió de la red. Consulte la excepción interna para obtener más información. + + Invalid MIME content-type header encountered on read. + Invalid MIME content-type header encountered on read. + + + + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + + + + Content stream can be retrieved from MIME message only once. + Content stream can be retrieved from MIME message only once. + + + + '{0}' MIME header is specified multiple times. + '{0}' MIME header is specified multiple times. + + + + Malformed header. + Malformed header. + + + + Reset called on MIME header reader before end of file. + Reset called on MIME header reader before end of file. + + + + Unexpected end of file. + Unexpected end of file. + + + + Invalid mime-version header encountered on read. + Invalid mime-version header encountered on read. + + + + Cannot call Close on MIME writer in state '{0}'. + Cannot call Close on MIME writer in state '{0}'. + + + + MIME writer cannot write content in state '{0}'. + MIME writer cannot write content in state '{0}'. + + + + MIME writer cannot write MIME header in state '{0}'. + MIME writer cannot write MIME header in state '{0}'. + + + + MIME writer cannot start new MIME part in state '{0}'. + MIME writer cannot start new MIME part in state '{0}'. + + + + MIME writer cannot start preface in '{0}' state. + MIME writer cannot start preface in '{0}' state. + + The incoming message was signed with a token which was different from what used to encrypt the body. This was not expected. El mensaje entrante se firmó con un token que era diferente del que solía cifrar el cuerpo. Esto no se esperaba. @@ -1817,6 +1887,156 @@ El RequestSecurityTokenResponseCollection recibido tiene más de un elemento RequestSecurityTokenResponse. Sólo se esperaba un elemento RequestSecurityTokenResponse. + + '{0}' not a valid MIME boundary. + '{0}' not a valid MIME boundary. + + + + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + + + + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + + + + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + + + + contentType must be non-zero length string. + contentType must be non-zero length string. + + + + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + + + + MessageVersion '{0}' not supported by MTOM encoder. + MessageVersion '{0}' not supported by MTOM encoder. + + + + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + + + + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + + + + URI specified for MIME part Content-ID cannot be empty. + URI specified for MIME part Content-ID cannot be empty. + + + + Invalid start URI for infoset '{0}'. + Invalid start URI for infoset '{0}'. + + + + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + + + + Content-Type header for MTOM message not found. + Content-Type header for MTOM message not found. + + + + MTOM message not valid. Does not contain correctly formatted content following headers. + MTOM message not valid. Does not contain correctly formatted content following headers. + + + + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + + + + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + + + + MTOM messages must have type '{0}'. + MTOM messages must have type '{0}'. + + + + MTOM messages must have media type '{0}' and media subtype '{1}'. + MTOM messages must have media type '{0}' and media subtype '{1}'. + + + + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + + + + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + + + + MIME part with Content-ID '{0}' not found. + MIME part with Content-ID '{0}' not found. + + + + Content-Type header for root MIME part not found. + Content-Type header for root MIME part not found. + + + + Root MIME part must have media type '{0}' and media subtype '{1}'. + Root MIME part must have media type '{0}' and media subtype '{1}'. + + + + Root MIME part containing infoset not found. + Root MIME part containing infoset not found. + + + + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + + + + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + + + + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + + + + Mandatory attribute '{0}' not found on XOP Include element. + Mandatory attribute '{0}' not found on XOP Include element. + + + + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + + + + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + + The extensions cannot contain an Identity if one is supplied as a constructor argument. Las extensiones no pueden contener una identidad si se proporciona una como argumento de constructor. @@ -2157,6 +2377,11 @@ El algoritmo de clave para esta clave pública no es compatible. + + Read not supported on stream '{0}'. + Read not supported on stream '{0}'. + + The channel received an unexpected fault input message while closing. The fault reason given is: '{0}' El canal recibió un mensaje de entrada de error inesperado al cerrarse. Razón del error: "{0}" @@ -2557,6 +2782,11 @@ No se puede agregar el elemento EndpointDispatcher a más de un elemento ChannelDispatcher. + + Error creating a reader for the MTOM message + Error creating a reader for the MTOM message + + Server returned an invalid SOAP Fault. Please see InnerException for more details. El servidor devolvió un error SOAP no válido. Consulte InnerException para obtener más información. @@ -3332,6 +3562,11 @@ El requisito de token tiene un tipo no esperado "{1}" para la propiedad "{0}". El tipo de propiedad esperado es "{2}". + + Seek not supported on stream '{0}'. + Seek not supported on stream '{0}'. + + You cannot Send messages on a channel after CloseOutputSession has been called. No se pueden enviar mensajes en un canal después de llamar a CloseOutputSession. @@ -4392,6 +4627,16 @@ El servidor no aceptó la solicitud de conexión. Es posible que la versión del subprotocolo WebSocket de su cliente no coincida con el del servidor ("{0}"). + + An internal error has occurred. Overflow on MIME writer buffer. + An internal error has occurred. Overflow on MIME writer buffer. + + + + Write not supported on stream '{0}'. + Write not supported on stream '{0}'. + + The remote endpoint has sent an fault message with an unexpected sequence identifier over a session. The fault may be intended for a different session. The fault reason is: {0} The reliable session was faulted. El extremo remoto envió un mensaje de error con un identificador de secuencia inesperado en una sesión. Es posible que el error corresponda a una sesión diferente. La razón del error es: {0}. Se generó un error en la sesión confiable. @@ -4462,6 +4707,11 @@ No se encuentra el valor "{0}" en la cadena de diccionario. + + Array too small. + Array too small. + + An internal error has occurred. The XML buffer is not in the correct state to perform the operation. Error interno. El búfer XML no se encuentra en el estado correcto para llevar a cabo la operación. @@ -4472,6 +4722,16 @@ El tamaño necesario para almacenar en búfer el contenido XML superó la cuota del búfer. + + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + + + + The characters '{0}' at offset {1} are not a valid BinHex sequence. + The characters '{0}' at offset {1} are not a valid BinHex sequence. + + The value '{0}' cannot be parsed as the type '{1}'. El valor "{0}" no se puede analizar como el tipo "{1}". @@ -4487,6 +4747,21 @@ Falta el valor de atributo xml:lang requerido. + + Line {0}, position {1}. + Line {0}, position {1}. + + + + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + + + + The XmlWriter is closed. + The XmlWriter is closed. + + '{0}' is an invalid XmlNodeType. "{0}" es un XmlNodeType no válido. diff --git a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.fr.xlf b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.fr.xlf index 7a247a61943..4825a600c73 100644 --- a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.fr.xlf +++ b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.fr.xlf @@ -1602,6 +1602,11 @@ MaxBufferSize ne peut pas avoir une valeur supérieure à MaxReceivedMessageSize. + + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + + The maximum message size quota for incoming messages ({0}) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. Le quota de taille maximale des messages entrants ({0}) a été dépassé. Pour augmenter le quota, utilisez la propriété MaxReceivedMessageSize sur l'élément de liaison approprié. @@ -1762,6 +1767,71 @@ Un problème s'est produit avec le code XML qui a été reçu du réseau. Pour plus d'informations, consultez l'exception interne. + + Invalid MIME content-type header encountered on read. + Invalid MIME content-type header encountered on read. + + + + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + + + + Content stream can be retrieved from MIME message only once. + Content stream can be retrieved from MIME message only once. + + + + '{0}' MIME header is specified multiple times. + '{0}' MIME header is specified multiple times. + + + + Malformed header. + Malformed header. + + + + Reset called on MIME header reader before end of file. + Reset called on MIME header reader before end of file. + + + + Unexpected end of file. + Unexpected end of file. + + + + Invalid mime-version header encountered on read. + Invalid mime-version header encountered on read. + + + + Cannot call Close on MIME writer in state '{0}'. + Cannot call Close on MIME writer in state '{0}'. + + + + MIME writer cannot write content in state '{0}'. + MIME writer cannot write content in state '{0}'. + + + + MIME writer cannot write MIME header in state '{0}'. + MIME writer cannot write MIME header in state '{0}'. + + + + MIME writer cannot start new MIME part in state '{0}'. + MIME writer cannot start new MIME part in state '{0}'. + + + + MIME writer cannot start preface in '{0}' state. + MIME writer cannot start preface in '{0}' state. + + The incoming message was signed with a token which was different from what used to encrypt the body. This was not expected. Le message entrant a été signé avec un jeton qui était différent de celui utilisé pour chiffrer le corps. Cette situation est inattendue. @@ -1817,6 +1887,156 @@ La réponse RequestSecurityTokenResponseCollection reçue comporte plusieurs éléments RequestSecurityTokenResponse. Un seul élément RequestSecurityTokenResponse était attendu. + + '{0}' not a valid MIME boundary. + '{0}' not a valid MIME boundary. + + + + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + + + + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + + + + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + + + + contentType must be non-zero length string. + contentType must be non-zero length string. + + + + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + + + + MessageVersion '{0}' not supported by MTOM encoder. + MessageVersion '{0}' not supported by MTOM encoder. + + + + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + + + + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + + + + URI specified for MIME part Content-ID cannot be empty. + URI specified for MIME part Content-ID cannot be empty. + + + + Invalid start URI for infoset '{0}'. + Invalid start URI for infoset '{0}'. + + + + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + + + + Content-Type header for MTOM message not found. + Content-Type header for MTOM message not found. + + + + MTOM message not valid. Does not contain correctly formatted content following headers. + MTOM message not valid. Does not contain correctly formatted content following headers. + + + + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + + + + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + + + + MTOM messages must have type '{0}'. + MTOM messages must have type '{0}'. + + + + MTOM messages must have media type '{0}' and media subtype '{1}'. + MTOM messages must have media type '{0}' and media subtype '{1}'. + + + + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + + + + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + + + + MIME part with Content-ID '{0}' not found. + MIME part with Content-ID '{0}' not found. + + + + Content-Type header for root MIME part not found. + Content-Type header for root MIME part not found. + + + + Root MIME part must have media type '{0}' and media subtype '{1}'. + Root MIME part must have media type '{0}' and media subtype '{1}'. + + + + Root MIME part containing infoset not found. + Root MIME part containing infoset not found. + + + + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + + + + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + + + + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + + + + Mandatory attribute '{0}' not found on XOP Include element. + Mandatory attribute '{0}' not found on XOP Include element. + + + + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + + + + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + + The extensions cannot contain an Identity if one is supplied as a constructor argument. Les extensions ne peuvent pas contenir Identity, s'il en existe un fourni en tant qu'argument de constructeur. @@ -2157,6 +2377,11 @@ L’algorithme de clé pour cette clé publique n’est pas pris en charge. + + Read not supported on stream '{0}'. + Read not supported on stream '{0}'. + + The channel received an unexpected fault input message while closing. The fault reason given is: '{0}' Le canal a reçu un message d'entrée d'erreur inattendu durant sa fermeture. La raison de l'erreur donnée est : '{0}' @@ -2557,6 +2782,11 @@ Impossible d'ajouter EndpointDispatcher à plusieurs ChannelDispatcher. + + Error creating a reader for the MTOM message + Error creating a reader for the MTOM message + + Server returned an invalid SOAP Fault. Please see InnerException for more details. Le serveur a retourné une erreur SOAP non valide. Pour plus d'informations, consultez InnerException. @@ -3332,6 +3562,11 @@ L'exigence du jeton présente un type '{1}' inattendu pour la propriété '{0}'. Le type de propriété attendu est '{2}'. + + Seek not supported on stream '{0}'. + Seek not supported on stream '{0}'. + + You cannot Send messages on a channel after CloseOutputSession has been called. Vous ne pouvez pas envoyer de message sur un canal après l'appel de CloseOutputSession. @@ -4392,6 +4627,16 @@ Le serveur a refusé la demande de connexion. Il est possible que la version du protocole WebSocket sur votre client ne corresponde pas à la version située sur le serveur ('{0}'). + + An internal error has occurred. Overflow on MIME writer buffer. + An internal error has occurred. Overflow on MIME writer buffer. + + + + Write not supported on stream '{0}'. + Write not supported on stream '{0}'. + + The remote endpoint has sent an fault message with an unexpected sequence identifier over a session. The fault may be intended for a different session. The fault reason is: {0} The reliable session was faulted. Le point de terminaison distant a envoyé un message de faute avec un identificateur de séquence inattendu sur une session. La faute pourrait concerner une autre session. La raison de la faute est : {0} La session fiable a généré une erreur. @@ -4462,6 +4707,11 @@ Impossible de localiser la valeur '{0}' dans la chaîne de dictionnaire. + + Array too small. + Array too small. + + An internal error has occurred. The XML buffer is not in the correct state to perform the operation. Une erreur interne s'est produite. La mémoire tampon XML n'est pas dans l'état approprié pour effectuer l'opération. @@ -4472,6 +4722,16 @@ La taille nécessaire à la mise en mémoire tampon du contenu XML a dépassé le quota de mémoire tampon. + + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + + + + The characters '{0}' at offset {1} are not a valid BinHex sequence. + The characters '{0}' at offset {1} are not a valid BinHex sequence. + + The value '{0}' cannot be parsed as the type '{1}'. Impossible d'analyser la valeur '{0}' en tant que type '{1}'. @@ -4487,6 +4747,21 @@ La valeur de l'attribut xml:lang est manquante. + + Line {0}, position {1}. + Line {0}, position {1}. + + + + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + + + + The XmlWriter is closed. + The XmlWriter is closed. + + '{0}' is an invalid XmlNodeType. '{0}' est un XmlNodeType non valide. diff --git a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.it.xlf b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.it.xlf index 86c0b8139f6..fdf2bf031bd 100644 --- a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.it.xlf +++ b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.it.xlf @@ -1602,6 +1602,11 @@ Il valore di MaxBufferSize non deve superare quello di MaxReceivedMessageSize. + + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + + The maximum message size quota for incoming messages ({0}) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. È stata superata la quota massima delle dimensioni per i messaggi in arrivo ({0}). Per aumentare la quota, usare la proprietà MaxReceivedMessageSize nell'elemento di binding appropriato. @@ -1762,6 +1767,71 @@ Si è verificato un problema con il codice XML ricevuto dalla rete. Per maggiori dettagli, vedere l'eccezione interna. + + Invalid MIME content-type header encountered on read. + Invalid MIME content-type header encountered on read. + + + + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + + + + Content stream can be retrieved from MIME message only once. + Content stream can be retrieved from MIME message only once. + + + + '{0}' MIME header is specified multiple times. + '{0}' MIME header is specified multiple times. + + + + Malformed header. + Malformed header. + + + + Reset called on MIME header reader before end of file. + Reset called on MIME header reader before end of file. + + + + Unexpected end of file. + Unexpected end of file. + + + + Invalid mime-version header encountered on read. + Invalid mime-version header encountered on read. + + + + Cannot call Close on MIME writer in state '{0}'. + Cannot call Close on MIME writer in state '{0}'. + + + + MIME writer cannot write content in state '{0}'. + MIME writer cannot write content in state '{0}'. + + + + MIME writer cannot write MIME header in state '{0}'. + MIME writer cannot write MIME header in state '{0}'. + + + + MIME writer cannot start new MIME part in state '{0}'. + MIME writer cannot start new MIME part in state '{0}'. + + + + MIME writer cannot start preface in '{0}' state. + MIME writer cannot start preface in '{0}' state. + + The incoming message was signed with a token which was different from what used to encrypt the body. This was not expected. Errore imprevisto. Messaggio in ingresso firmato con un token diverso da quello utilizzato per crittografare il corpo. @@ -1817,6 +1887,156 @@ Il valore RequestSecurityTokenResponseCollection ricevuto ha più di un elemento RequestSecurityTokenResponse. Era previsto solo un elemento RequestSecurityTokenResponse. + + '{0}' not a valid MIME boundary. + '{0}' not a valid MIME boundary. + + + + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + + + + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + + + + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + + + + contentType must be non-zero length string. + contentType must be non-zero length string. + + + + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + + + + MessageVersion '{0}' not supported by MTOM encoder. + MessageVersion '{0}' not supported by MTOM encoder. + + + + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + + + + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + + + + URI specified for MIME part Content-ID cannot be empty. + URI specified for MIME part Content-ID cannot be empty. + + + + Invalid start URI for infoset '{0}'. + Invalid start URI for infoset '{0}'. + + + + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + + + + Content-Type header for MTOM message not found. + Content-Type header for MTOM message not found. + + + + MTOM message not valid. Does not contain correctly formatted content following headers. + MTOM message not valid. Does not contain correctly formatted content following headers. + + + + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + + + + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + + + + MTOM messages must have type '{0}'. + MTOM messages must have type '{0}'. + + + + MTOM messages must have media type '{0}' and media subtype '{1}'. + MTOM messages must have media type '{0}' and media subtype '{1}'. + + + + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + + + + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + + + + MIME part with Content-ID '{0}' not found. + MIME part with Content-ID '{0}' not found. + + + + Content-Type header for root MIME part not found. + Content-Type header for root MIME part not found. + + + + Root MIME part must have media type '{0}' and media subtype '{1}'. + Root MIME part must have media type '{0}' and media subtype '{1}'. + + + + Root MIME part containing infoset not found. + Root MIME part containing infoset not found. + + + + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + + + + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + + + + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + + + + Mandatory attribute '{0}' not found on XOP Include element. + Mandatory attribute '{0}' not found on XOP Include element. + + + + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + + + + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + + The extensions cannot contain an Identity if one is supplied as a constructor argument. L'estensione non può contenere un elemento Identity se ne è già stato specificato uno come argomento del costruttore. @@ -2157,6 +2377,11 @@ L'algoritmo della chiave per questa chiave pubblica non è supportato. + + Read not supported on stream '{0}'. + Read not supported on stream '{0}'. + + The channel received an unexpected fault input message while closing. The fault reason given is: '{0}' Il canale ha ricevuto un messaggio input di errore imprevisto durante la chiusura. Motivo dell'errore: '{0}' @@ -2557,6 +2782,11 @@ Non è possibile aggiungere EndpointDispatcher a più di un elemento ChannelDispatcher. + + Error creating a reader for the MTOM message + Error creating a reader for the MTOM message + + Server returned an invalid SOAP Fault. Please see InnerException for more details. Il server ha restituito un errore SOAP non valido. Per maggiori dettagli, vedere InnerException. @@ -3332,6 +3562,11 @@ Il tipo '{1}' della proprietà '{0}' non è previsto per il requisito del token. Il tipo previsto della proprietà è '{2}'. + + Seek not supported on stream '{0}'. + Seek not supported on stream '{0}'. + + You cannot Send messages on a channel after CloseOutputSession has been called. Non è possibile chiamare Send sui messaggi in un canale dopo aver chiamato CloseOutputSession. @@ -4392,6 +4627,16 @@ Il server non ha accettato la richiesta di connessione. È possibile che la versione del protocollo WebSocket nel client non corrisponda a quella nel server ('{0}'). + + An internal error has occurred. Overflow on MIME writer buffer. + An internal error has occurred. Overflow on MIME writer buffer. + + + + Write not supported on stream '{0}'. + Write not supported on stream '{0}'. + + The remote endpoint has sent an fault message with an unexpected sequence identifier over a session. The fault may be intended for a different session. The fault reason is: {0} The reliable session was faulted. L'endpoint remoto ha inviato un messaggio di errore con un identificatore di sequenza imprevisto in una sessione. È possibile che l'errore fosse destinato a una sessione diversa. Il motivo dell'errore è: {0} Sessione affidabile non riuscita. @@ -4462,6 +4707,11 @@ Il valore '{0}' non è stato trovato nella stringa del dizionario. + + Array too small. + Array too small. + + An internal error has occurred. The XML buffer is not in the correct state to perform the operation. Si è verificato un errore interno. Lo stato del buffer XML non è corretto per eseguire l'operazione. @@ -4472,6 +4722,16 @@ Le dimensioni necessarie per memorizzare il contenuto XML nel buffer superano la quota del buffer. + + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + + + + The characters '{0}' at offset {1} are not a valid BinHex sequence. + The characters '{0}' at offset {1} are not a valid BinHex sequence. + + The value '{0}' cannot be parsed as the type '{1}'. Il valore '{0}' non può essere analizzato come tipo '{1}'. @@ -4487,6 +4747,21 @@ Manca il valore dell'attributo xml:lang. + + Line {0}, position {1}. + Line {0}, position {1}. + + + + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + + + + The XmlWriter is closed. + The XmlWriter is closed. + + '{0}' is an invalid XmlNodeType. '{0}' è un elemento XmlNodeType non valido. diff --git a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.ja.xlf b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.ja.xlf index 45c30b4f5e8..7af41fa32ce 100644 --- a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.ja.xlf +++ b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.ja.xlf @@ -1602,6 +1602,11 @@ MaxBufferSize の値は、MaxReceivedMessageSize の値以下である必要があります。 + + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + + The maximum message size quota for incoming messages ({0}) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. 受信メッセージの最大メッセージ サイズ クォータ ({0}) を超えました。このクォータを増やすには、適切なバインディング要素の MaxReceivedMessageSize プロパティを使用してください。 @@ -1762,6 +1767,71 @@ ネットワークから受信した XML に問題があります。詳細については、内部例外を参照してください。 + + Invalid MIME content-type header encountered on read. + Invalid MIME content-type header encountered on read. + + + + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + + + + Content stream can be retrieved from MIME message only once. + Content stream can be retrieved from MIME message only once. + + + + '{0}' MIME header is specified multiple times. + '{0}' MIME header is specified multiple times. + + + + Malformed header. + Malformed header. + + + + Reset called on MIME header reader before end of file. + Reset called on MIME header reader before end of file. + + + + Unexpected end of file. + Unexpected end of file. + + + + Invalid mime-version header encountered on read. + Invalid mime-version header encountered on read. + + + + Cannot call Close on MIME writer in state '{0}'. + Cannot call Close on MIME writer in state '{0}'. + + + + MIME writer cannot write content in state '{0}'. + MIME writer cannot write content in state '{0}'. + + + + MIME writer cannot write MIME header in state '{0}'. + MIME writer cannot write MIME header in state '{0}'. + + + + MIME writer cannot start new MIME part in state '{0}'. + MIME writer cannot start new MIME part in state '{0}'. + + + + MIME writer cannot start preface in '{0}' state. + MIME writer cannot start preface in '{0}' state. + + The incoming message was signed with a token which was different from what used to encrypt the body. This was not expected. 受信メッセージは、本文を暗号化するのに使用されたものと異なるトークンを使用して署名されています。これは適切な処理ではありません。 @@ -1817,6 +1887,156 @@ 受信された RequestSecurityTokenResponseCollection には複数の RequestSecurityTokenResponse 要素があります。想定された RequestSecurityTokenResponse 要素は 1 つだけです。 + + '{0}' not a valid MIME boundary. + '{0}' not a valid MIME boundary. + + + + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + + + + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + + + + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + + + + contentType must be non-zero length string. + contentType must be non-zero length string. + + + + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + + + + MessageVersion '{0}' not supported by MTOM encoder. + MessageVersion '{0}' not supported by MTOM encoder. + + + + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + + + + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + + + + URI specified for MIME part Content-ID cannot be empty. + URI specified for MIME part Content-ID cannot be empty. + + + + Invalid start URI for infoset '{0}'. + Invalid start URI for infoset '{0}'. + + + + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + + + + Content-Type header for MTOM message not found. + Content-Type header for MTOM message not found. + + + + MTOM message not valid. Does not contain correctly formatted content following headers. + MTOM message not valid. Does not contain correctly formatted content following headers. + + + + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + + + + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + + + + MTOM messages must have type '{0}'. + MTOM messages must have type '{0}'. + + + + MTOM messages must have media type '{0}' and media subtype '{1}'. + MTOM messages must have media type '{0}' and media subtype '{1}'. + + + + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + + + + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + + + + MIME part with Content-ID '{0}' not found. + MIME part with Content-ID '{0}' not found. + + + + Content-Type header for root MIME part not found. + Content-Type header for root MIME part not found. + + + + Root MIME part must have media type '{0}' and media subtype '{1}'. + Root MIME part must have media type '{0}' and media subtype '{1}'. + + + + Root MIME part containing infoset not found. + Root MIME part containing infoset not found. + + + + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + + + + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + + + + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + + + + Mandatory attribute '{0}' not found on XOP Include element. + Mandatory attribute '{0}' not found on XOP Include element. + + + + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + + + + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + + The extensions cannot contain an Identity if one is supplied as a constructor argument. コンストラクターの引数として提供されている場合、拡張に ID を含めることはできません。 @@ -2157,6 +2377,11 @@ この公開キーのキー アルゴリズムはサポートされていません。 + + Read not supported on stream '{0}'. + Read not supported on stream '{0}'. + + The channel received an unexpected fault input message while closing. The fault reason given is: '{0}' チャネルを閉じているときに、予期しないフォールト入力メッセージを受信しました。提示されたフォールトの原因は '{0}' です。 @@ -2557,6 +2782,11 @@ EndpointDispatcher を複数の ChannelDispatcher に追加することはできません。 + + Error creating a reader for the MTOM message + Error creating a reader for the MTOM message + + Server returned an invalid SOAP Fault. Please see InnerException for more details. サーバーから無効な SOAP フォールトが返されました。詳細については、InnerException を参照してください。 @@ -3332,6 +3562,11 @@ トークンの要件に、プロパティ '{0}' では予期されていない型 '{1}' が含まれています。予期されたプロパティの型は '{2}' です。 + + Seek not supported on stream '{0}'. + Seek not supported on stream '{0}'. + + You cannot Send messages on a channel after CloseOutputSession has been called. CloseOutputSession の呼び出し後にチャネルでメッセージを送信することはできません。 @@ -4392,6 +4627,16 @@ サーバーが接続要求を受け入れませんでした。クライアントの WebSocket プロトコルのバージョンが、サーバー ('{0}') のものと一致していない可能性があります。 + + An internal error has occurred. Overflow on MIME writer buffer. + An internal error has occurred. Overflow on MIME writer buffer. + + + + Write not supported on stream '{0}'. + Write not supported on stream '{0}'. + + The remote endpoint has sent an fault message with an unexpected sequence identifier over a session. The fault may be intended for a different session. The fault reason is: {0} The reliable session was faulted. リモート エンドポイントは、予期しないシーケンス ID を持つフォールト メッセージをセッション経由で送信しました。このフォールトは異なるセッションを対象にしている可能性があります。フォールトの原因は {0} です。信頼できるセッションは途中終了されました。 @@ -4462,6 +4707,11 @@ 辞書の文字列に '{0}' 値が見つかりません。 + + Array too small. + Array too small. + + An internal error has occurred. The XML buffer is not in the correct state to perform the operation. 内部エラーが発生しました。XML バッファーがこの操作を実行するための適切な状態にありません。 @@ -4472,6 +4722,16 @@ XML コンテンツのバッファリングに必要なサイズがバッファー クォータを超過しました。 + + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + + + + The characters '{0}' at offset {1} are not a valid BinHex sequence. + The characters '{0}' at offset {1} are not a valid BinHex sequence. + + The value '{0}' cannot be parsed as the type '{1}'. 値 '{0}' を型 '{1}' として解析できません。 @@ -4487,6 +4747,21 @@ 必要な xml:lang 属性値がありません。 + + Line {0}, position {1}. + Line {0}, position {1}. + + + + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + + + + The XmlWriter is closed. + The XmlWriter is closed. + + '{0}' is an invalid XmlNodeType. '{0}' は、XmlNodeType としては無効です。 diff --git a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.ko.xlf b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.ko.xlf index b4c496e3291..d9dee886b5a 100644 --- a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.ko.xlf +++ b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.ko.xlf @@ -1602,6 +1602,11 @@ MaxBufferSize는 MaxReceivedMessageSize를 초과해서는 안 됩니다. + + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + + The maximum message size quota for incoming messages ({0}) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. 들어오는 메시지의 최대 메시지 크기 할당량({0})을 초과했습니다. 할당량을 늘리려면 적합한 바인딩 요소에서 MaxReceivedMessageSize 속성을 사용하세요. @@ -1762,6 +1767,71 @@ 네트워크에서 수신한 XML에 문제가 있습니다. 자세한 내용은 내부 예외를 참조하세요. + + Invalid MIME content-type header encountered on read. + Invalid MIME content-type header encountered on read. + + + + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + + + + Content stream can be retrieved from MIME message only once. + Content stream can be retrieved from MIME message only once. + + + + '{0}' MIME header is specified multiple times. + '{0}' MIME header is specified multiple times. + + + + Malformed header. + Malformed header. + + + + Reset called on MIME header reader before end of file. + Reset called on MIME header reader before end of file. + + + + Unexpected end of file. + Unexpected end of file. + + + + Invalid mime-version header encountered on read. + Invalid mime-version header encountered on read. + + + + Cannot call Close on MIME writer in state '{0}'. + Cannot call Close on MIME writer in state '{0}'. + + + + MIME writer cannot write content in state '{0}'. + MIME writer cannot write content in state '{0}'. + + + + MIME writer cannot write MIME header in state '{0}'. + MIME writer cannot write MIME header in state '{0}'. + + + + MIME writer cannot start new MIME part in state '{0}'. + MIME writer cannot start new MIME part in state '{0}'. + + + + MIME writer cannot start preface in '{0}' state. + MIME writer cannot start preface in '{0}' state. + + The incoming message was signed with a token which was different from what used to encrypt the body. This was not expected. 들어오는 메시지가 본문을 암호화하는 데 사용된 토큰과 다른 토큰으로 서명되었습니다. 이것은 예기치 않은 동작입니다. @@ -1817,6 +1887,156 @@ 받은 RequestSecurityTokenResponseCollection에 둘 이상의 RequestSecurityTokenResponse 요소가 있습니다. RequestSecurityTokenResponse 요소는 하나만 필요합니다. + + '{0}' not a valid MIME boundary. + '{0}' not a valid MIME boundary. + + + + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + + + + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + + + + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + + + + contentType must be non-zero length string. + contentType must be non-zero length string. + + + + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + + + + MessageVersion '{0}' not supported by MTOM encoder. + MessageVersion '{0}' not supported by MTOM encoder. + + + + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + + + + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + + + + URI specified for MIME part Content-ID cannot be empty. + URI specified for MIME part Content-ID cannot be empty. + + + + Invalid start URI for infoset '{0}'. + Invalid start URI for infoset '{0}'. + + + + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + + + + Content-Type header for MTOM message not found. + Content-Type header for MTOM message not found. + + + + MTOM message not valid. Does not contain correctly formatted content following headers. + MTOM message not valid. Does not contain correctly formatted content following headers. + + + + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + + + + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + + + + MTOM messages must have type '{0}'. + MTOM messages must have type '{0}'. + + + + MTOM messages must have media type '{0}' and media subtype '{1}'. + MTOM messages must have media type '{0}' and media subtype '{1}'. + + + + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + + + + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + + + + MIME part with Content-ID '{0}' not found. + MIME part with Content-ID '{0}' not found. + + + + Content-Type header for root MIME part not found. + Content-Type header for root MIME part not found. + + + + Root MIME part must have media type '{0}' and media subtype '{1}'. + Root MIME part must have media type '{0}' and media subtype '{1}'. + + + + Root MIME part containing infoset not found. + Root MIME part containing infoset not found. + + + + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + + + + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + + + + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + + + + Mandatory attribute '{0}' not found on XOP Include element. + Mandatory attribute '{0}' not found on XOP Include element. + + + + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + + + + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + + The extensions cannot contain an Identity if one is supplied as a constructor argument. 생성자 인수로 제공되는 경우에는 확장에 ID가 포함될 수 없습니다. @@ -2157,6 +2377,11 @@ 이 퍼블릭 키에 대한 키 알고리즘은 지원되지 않습니다. + + Read not supported on stream '{0}'. + Read not supported on stream '{0}'. + + The channel received an unexpected fault input message while closing. The fault reason given is: '{0}' 채널이 닫히는 도중에 예기치 않은 오류 입력 메시지를 수신했습니다. 주어진 오류 원인은 '{0}'입니다. @@ -2557,6 +2782,11 @@ EndpointDispatcher를 두 개 이상의 ChannelDispatcher에 추가할 수 없습니다. + + Error creating a reader for the MTOM message + Error creating a reader for the MTOM message + + Server returned an invalid SOAP Fault. Please see InnerException for more details. 서버가 잘못된 SOAP 오류를 반환했습니다. 자세한 내용은 InnerException을 참조하세요. @@ -3332,6 +3562,11 @@ 토큰 요구 사항에서 '{0}' 속성에 대해 예기치 않은 형식 '{1}'이(가) 있습니다. 필요한 속성 형식은 '{2}'입니다. + + Seek not supported on stream '{0}'. + Seek not supported on stream '{0}'. + + You cannot Send messages on a channel after CloseOutputSession has been called. CloseOutputSession이 호출된 후에 채널에서 메시지를 보낼 수 없습니다. @@ -4392,6 +4627,16 @@ 서버에서 연결 요청을 수락하지 않았습니다. 클라이언트의 WebSocket 프로토콜 버전이 서버의 프로토콜 버전('{0}')과 일치하지 않을 수 있습니다. + + An internal error has occurred. Overflow on MIME writer buffer. + An internal error has occurred. Overflow on MIME writer buffer. + + + + Write not supported on stream '{0}'. + Write not supported on stream '{0}'. + + The remote endpoint has sent an fault message with an unexpected sequence identifier over a session. The fault may be intended for a different session. The fault reason is: {0} The reliable session was faulted. 원격 끝점이 세션을 통해 필요하지 않은 시퀀스 식별자가 있는 오류 메시지를 보냈습니다. 오류는 다른 세션을 위한 것일 수 있습니다. 오류 원인은 {0}입니다. 신뢰 세션에 오류가 발생했습니다. @@ -4462,6 +4707,11 @@ 사전 문자열에 '{0}' 값이 없습니다. + + Array too small. + Array too small. + + An internal error has occurred. The XML buffer is not in the correct state to perform the operation. 내부 오류가 발생했습니다. XML 버퍼가 올바른 상태가 아니므로 작업을 수행할 수 없습니다. @@ -4472,6 +4722,16 @@ XML 콘텐츠를 버퍼링하는 데 필요한 크기가 버퍼 할당량을 초과했습니다. + + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + + + + The characters '{0}' at offset {1} are not a valid BinHex sequence. + The characters '{0}' at offset {1} are not a valid BinHex sequence. + + The value '{0}' cannot be parsed as the type '{1}'. '{0}' 값을 '{1}' 형식으로 구문 분석할 수 없습니다. @@ -4487,6 +4747,21 @@ 필수 xml:lang 특성 값이 없습니다. + + Line {0}, position {1}. + Line {0}, position {1}. + + + + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + + + + The XmlWriter is closed. + The XmlWriter is closed. + + '{0}' is an invalid XmlNodeType. '{0}'은(는) 잘못된 XmlNodeType입니다. diff --git a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.pl.xlf b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.pl.xlf index 75b33e7a5f9..3949a1b93e7 100644 --- a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.pl.xlf +++ b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.pl.xlf @@ -1602,6 +1602,11 @@ Wartość MaxBufferSize nie może przekraczać wartości MaxReceivedMessageSize. + + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + + The maximum message size quota for incoming messages ({0}) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. Maksymalny przydział rozmiaru wiadomości dla wiadomości przychodzących ({0}) został przekroczony. Aby zwiększyć przydział, użyj właściwości MaxReceivedMessageSize we właściwym elemencie powiązania. @@ -1762,6 +1767,71 @@ Wystąpił problem z plikiem XML odebranym z sieci. Aby uzyskać szczegółowe informacje, zobacz wyjątek wewnętrzny. + + Invalid MIME content-type header encountered on read. + Invalid MIME content-type header encountered on read. + + + + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + + + + Content stream can be retrieved from MIME message only once. + Content stream can be retrieved from MIME message only once. + + + + '{0}' MIME header is specified multiple times. + '{0}' MIME header is specified multiple times. + + + + Malformed header. + Malformed header. + + + + Reset called on MIME header reader before end of file. + Reset called on MIME header reader before end of file. + + + + Unexpected end of file. + Unexpected end of file. + + + + Invalid mime-version header encountered on read. + Invalid mime-version header encountered on read. + + + + Cannot call Close on MIME writer in state '{0}'. + Cannot call Close on MIME writer in state '{0}'. + + + + MIME writer cannot write content in state '{0}'. + MIME writer cannot write content in state '{0}'. + + + + MIME writer cannot write MIME header in state '{0}'. + MIME writer cannot write MIME header in state '{0}'. + + + + MIME writer cannot start new MIME part in state '{0}'. + MIME writer cannot start new MIME part in state '{0}'. + + + + MIME writer cannot start preface in '{0}' state. + MIME writer cannot start preface in '{0}' state. + + The incoming message was signed with a token which was different from what used to encrypt the body. This was not expected. Wiadomość przychodząca została podpisana tokenem, który różni się od tokenu użytego do zaszyfrowania treści. Nie oczekiwano takiego zachowania. @@ -1817,6 +1887,156 @@ Odebrany schemat RequestSecurityTokenResponseCollection zawiera więcej niż jeden element RequestSecurityTokenResponse. Oczekiwano tylko jednego elementu RequestSecurityTokenResponse. + + '{0}' not a valid MIME boundary. + '{0}' not a valid MIME boundary. + + + + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + + + + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + + + + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + + + + contentType must be non-zero length string. + contentType must be non-zero length string. + + + + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + + + + MessageVersion '{0}' not supported by MTOM encoder. + MessageVersion '{0}' not supported by MTOM encoder. + + + + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + + + + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + + + + URI specified for MIME part Content-ID cannot be empty. + URI specified for MIME part Content-ID cannot be empty. + + + + Invalid start URI for infoset '{0}'. + Invalid start URI for infoset '{0}'. + + + + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + + + + Content-Type header for MTOM message not found. + Content-Type header for MTOM message not found. + + + + MTOM message not valid. Does not contain correctly formatted content following headers. + MTOM message not valid. Does not contain correctly formatted content following headers. + + + + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + + + + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + + + + MTOM messages must have type '{0}'. + MTOM messages must have type '{0}'. + + + + MTOM messages must have media type '{0}' and media subtype '{1}'. + MTOM messages must have media type '{0}' and media subtype '{1}'. + + + + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + + + + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + + + + MIME part with Content-ID '{0}' not found. + MIME part with Content-ID '{0}' not found. + + + + Content-Type header for root MIME part not found. + Content-Type header for root MIME part not found. + + + + Root MIME part must have media type '{0}' and media subtype '{1}'. + Root MIME part must have media type '{0}' and media subtype '{1}'. + + + + Root MIME part containing infoset not found. + Root MIME part containing infoset not found. + + + + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + + + + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + + + + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + + + + Mandatory attribute '{0}' not found on XOP Include element. + Mandatory attribute '{0}' not found on XOP Include element. + + + + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + + + + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + + The extensions cannot contain an Identity if one is supplied as a constructor argument. Rozszerzenia nie mogą zawierać tożsamości, jeśli jest ona podawana jako argument konstruktora. @@ -2157,6 +2377,11 @@ Algorytm klucza dla tego klucza publicznego nie jest obsługiwany. + + Read not supported on stream '{0}'. + Read not supported on stream '{0}'. + + The channel received an unexpected fault input message while closing. The fault reason given is: '{0}' Podczas zamykania kanał odebrał nieoczekiwany komunikat wejściowy o błędzie. Podana przyczyna błędu to: „{0}” @@ -2557,6 +2782,11 @@ Elementu EndpointDispatcher nie można dodać do więcej niż jednego elementu ChannelDispatcher. + + Error creating a reader for the MTOM message + Error creating a reader for the MTOM message + + Server returned an invalid SOAP Fault. Please see InnerException for more details. Serwer zwrócił nieprawidłowy błąd protokołu SOAP. Więcej informacji znajdziesz we właściwości InnerException. @@ -3332,6 +3562,11 @@ Wymaganie tokenu ma nieoczekiwany typ „{1}” dla właściwości „{0}”. Oczekiwanym typem właściwości jest „{2}”. + + Seek not supported on stream '{0}'. + Seek not supported on stream '{0}'. + + You cannot Send messages on a channel after CloseOutputSession has been called. Nie można wysyłać komunikatów za pośrednictwem kanału po wywołaniu metody CloseOutputSession. @@ -4392,6 +4627,16 @@ Serwer nie zaakceptował żądania połączenia. Być może wersja protokołu WebSocket używana przez klienta jest niezgodna z wersją używaną przez serwer („{0}”). + + An internal error has occurred. Overflow on MIME writer buffer. + An internal error has occurred. Overflow on MIME writer buffer. + + + + Write not supported on stream '{0}'. + Write not supported on stream '{0}'. + + The remote endpoint has sent an fault message with an unexpected sequence identifier over a session. The fault may be intended for a different session. The fault reason is: {0} The reliable session was faulted. Zdalny punkt końcowy wysłał komunikat o błędzie o nieoczekiwanym identyfikatorze sekwencji za pośrednictwem sesji. Błąd może dotyczyć innej sesji. Powód błędu: {0} Wystąpił błąd sesji uwierzytelnionej. @@ -4462,6 +4707,11 @@ Nie można odnaleźć wartości „{0}” w ciągu słownikowym. + + Array too small. + Array too small. + + An internal error has occurred. The XML buffer is not in the correct state to perform the operation. Wystąpił błąd wewnętrzny. Stan buforu XML nie pozwala na wykonanie operacji. @@ -4472,6 +4722,16 @@ Rozmiar wymagany do buforowania zawartości XML przekroczył limit przydziału buforu. + + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + + + + The characters '{0}' at offset {1} are not a valid BinHex sequence. + The characters '{0}' at offset {1} are not a valid BinHex sequence. + + The value '{0}' cannot be parsed as the type '{1}'. Wartość „{0}” nie może być analizowana jako typ „{1}”. @@ -4487,6 +4747,21 @@ Brak wartości wymaganego atrybutu xml:lang. + + Line {0}, position {1}. + Line {0}, position {1}. + + + + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + + + + The XmlWriter is closed. + The XmlWriter is closed. + + '{0}' is an invalid XmlNodeType. Element „{0}” jest nieprawidłowym typem XmlNodeType. diff --git a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.pt-BR.xlf b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.pt-BR.xlf index a71c145f7d6..20ee073f2cf 100644 --- a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.pt-BR.xlf +++ b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.pt-BR.xlf @@ -1602,6 +1602,11 @@ MaxBufferSize não deve exceder MaxReceivedMessageSize. + + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + + The maximum message size quota for incoming messages ({0}) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. A cota máxima de tamanho de mensagens de entrada ({0}) foi excedida. Para aumentar a cota, use a propriedade MaxReceivedMessageSize no elemento de associação apropriado. @@ -1762,6 +1767,71 @@ Há um problema com o XML recebido da rede. Consulte a exceção interna para obter mais detalhes. + + Invalid MIME content-type header encountered on read. + Invalid MIME content-type header encountered on read. + + + + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + + + + Content stream can be retrieved from MIME message only once. + Content stream can be retrieved from MIME message only once. + + + + '{0}' MIME header is specified multiple times. + '{0}' MIME header is specified multiple times. + + + + Malformed header. + Malformed header. + + + + Reset called on MIME header reader before end of file. + Reset called on MIME header reader before end of file. + + + + Unexpected end of file. + Unexpected end of file. + + + + Invalid mime-version header encountered on read. + Invalid mime-version header encountered on read. + + + + Cannot call Close on MIME writer in state '{0}'. + Cannot call Close on MIME writer in state '{0}'. + + + + MIME writer cannot write content in state '{0}'. + MIME writer cannot write content in state '{0}'. + + + + MIME writer cannot write MIME header in state '{0}'. + MIME writer cannot write MIME header in state '{0}'. + + + + MIME writer cannot start new MIME part in state '{0}'. + MIME writer cannot start new MIME part in state '{0}'. + + + + MIME writer cannot start preface in '{0}' state. + MIME writer cannot start preface in '{0}' state. + + The incoming message was signed with a token which was different from what used to encrypt the body. This was not expected. A mensagem de entrada foi assinada com um token diferente do usado para criptografar o corpo. Isso não era esperado. @@ -1817,6 +1887,156 @@ O RequestSecurityTokenResponseCollection recebido tem mais de um elemento RequestSecurityTokenResponse. Somente um elemento RequestSecurityTokenResponse era esperado. + + '{0}' not a valid MIME boundary. + '{0}' not a valid MIME boundary. + + + + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + + + + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + + + + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + + + + contentType must be non-zero length string. + contentType must be non-zero length string. + + + + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + + + + MessageVersion '{0}' not supported by MTOM encoder. + MessageVersion '{0}' not supported by MTOM encoder. + + + + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + + + + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + + + + URI specified for MIME part Content-ID cannot be empty. + URI specified for MIME part Content-ID cannot be empty. + + + + Invalid start URI for infoset '{0}'. + Invalid start URI for infoset '{0}'. + + + + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + + + + Content-Type header for MTOM message not found. + Content-Type header for MTOM message not found. + + + + MTOM message not valid. Does not contain correctly formatted content following headers. + MTOM message not valid. Does not contain correctly formatted content following headers. + + + + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + + + + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + + + + MTOM messages must have type '{0}'. + MTOM messages must have type '{0}'. + + + + MTOM messages must have media type '{0}' and media subtype '{1}'. + MTOM messages must have media type '{0}' and media subtype '{1}'. + + + + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + + + + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + + + + MIME part with Content-ID '{0}' not found. + MIME part with Content-ID '{0}' not found. + + + + Content-Type header for root MIME part not found. + Content-Type header for root MIME part not found. + + + + Root MIME part must have media type '{0}' and media subtype '{1}'. + Root MIME part must have media type '{0}' and media subtype '{1}'. + + + + Root MIME part containing infoset not found. + Root MIME part containing infoset not found. + + + + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + + + + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + + + + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + + + + Mandatory attribute '{0}' not found on XOP Include element. + Mandatory attribute '{0}' not found on XOP Include element. + + + + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + + + + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + + The extensions cannot contain an Identity if one is supplied as a constructor argument. As extensões não poderão conter uma Identidade se uma for fornecida como argumento de construtor. @@ -2157,6 +2377,11 @@ O algoritmo chave para esta chave pública não é suportado. + + Read not supported on stream '{0}'. + Read not supported on stream '{0}'. + + The channel received an unexpected fault input message while closing. The fault reason given is: '{0}' O canal recebeu uma mensagem de entrada inesperada com falha durante o fechamento. O motivo determinado da falha é: '{0}' @@ -2557,6 +2782,11 @@ Não é possível adicionar um EndpointDispatcher a mais de um ChannelDispatcher. + + Error creating a reader for the MTOM message + Error creating a reader for the MTOM message + + Server returned an invalid SOAP Fault. Please see InnerException for more details. O servidor retornou uma Falha SOAP inválida. Consulte a InnerException para obter mais detalhes. @@ -3332,6 +3562,11 @@ O requisito de token tem um tipo inesperado '{1}' para a propriedade '{0}'. O tipo de propriedade esperado é '{2}'. + + Seek not supported on stream '{0}'. + Seek not supported on stream '{0}'. + + You cannot Send messages on a channel after CloseOutputSession has been called. Não é possível Enviar mensagens em um canal após CloseOutputSession ter sido chamado. @@ -4392,6 +4627,16 @@ O servidor não aceitou a solicitação de conexão. É possível que a versão do protocolo WebSocket no cliente não corresponda à versão no servidor ('{0}'). + + An internal error has occurred. Overflow on MIME writer buffer. + An internal error has occurred. Overflow on MIME writer buffer. + + + + Write not supported on stream '{0}'. + Write not supported on stream '{0}'. + + The remote endpoint has sent an fault message with an unexpected sequence identifier over a session. The fault may be intended for a different session. The fault reason is: {0} The reliable session was faulted. O ponto de extremidade remoto enviou uma mensagem de falha com um identificador de sequência inesperado em uma sessão. A falha pode ser destinada a uma sessão diferente. O motivo da falha é: {0} Falha na sessão confiável. @@ -4462,6 +4707,11 @@ Não é possível encontrar o valor '{0}' na cadeia de caracteres de dicionário. + + Array too small. + Array too small. + + An internal error has occurred. The XML buffer is not in the correct state to perform the operation. Erro interno. O buffer XML não está no estado correto para realizar a operação. @@ -4472,6 +4722,16 @@ O tamanho necessário para armazenar em buffer o conteúdo XML excedeu a cota do buffer. + + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + + + + The characters '{0}' at offset {1} are not a valid BinHex sequence. + The characters '{0}' at offset {1} are not a valid BinHex sequence. + + The value '{0}' cannot be parsed as the type '{1}'. O valor '{0}' não pode ser analisado como o tipo '{1}'. @@ -4487,6 +4747,21 @@ Falta o valor do atributo xml:lang obrigatório. + + Line {0}, position {1}. + Line {0}, position {1}. + + + + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + + + + The XmlWriter is closed. + The XmlWriter is closed. + + '{0}' is an invalid XmlNodeType. '{0}' é uma expressão XmlNodeType inválida. diff --git a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.ru.xlf b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.ru.xlf index 6523d913a9b..e4529a14186 100644 --- a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.ru.xlf +++ b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.ru.xlf @@ -1602,6 +1602,11 @@ Значение параметра MaxBufferSize не должно превышать значения параметра MaxReceivedMessageSize. + + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + + The maximum message size quota for incoming messages ({0}) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. Превышена квота на максимальный размер сообщения для входящих сообщений ({0}). Чтобы увеличить квоту, воспользуйтесь свойством MaxReceivedMessageSize соответствующего элемента привязки. @@ -1762,6 +1767,71 @@ Имеется проблема в XML-данных, полученных из сети. Подробнее см. в описании внутреннего исключения. + + Invalid MIME content-type header encountered on read. + Invalid MIME content-type header encountered on read. + + + + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + + + + Content stream can be retrieved from MIME message only once. + Content stream can be retrieved from MIME message only once. + + + + '{0}' MIME header is specified multiple times. + '{0}' MIME header is specified multiple times. + + + + Malformed header. + Malformed header. + + + + Reset called on MIME header reader before end of file. + Reset called on MIME header reader before end of file. + + + + Unexpected end of file. + Unexpected end of file. + + + + Invalid mime-version header encountered on read. + Invalid mime-version header encountered on read. + + + + Cannot call Close on MIME writer in state '{0}'. + Cannot call Close on MIME writer in state '{0}'. + + + + MIME writer cannot write content in state '{0}'. + MIME writer cannot write content in state '{0}'. + + + + MIME writer cannot write MIME header in state '{0}'. + MIME writer cannot write MIME header in state '{0}'. + + + + MIME writer cannot start new MIME part in state '{0}'. + MIME writer cannot start new MIME part in state '{0}'. + + + + MIME writer cannot start preface in '{0}' state. + MIME writer cannot start preface in '{0}' state. + + The incoming message was signed with a token which was different from what used to encrypt the body. This was not expected. Входящее сообщение было подписано токеном, отличающимся от токена, использованного для шифрования тела сообщения. Ожидалось, что токены будут одинаковы. @@ -1817,6 +1887,156 @@ Полученная коллекция RequestSecurityTokenResponseCollection содержит более одного элемента RequestSecurityTokenResponse. Ожидался только один элемент RequestSecurityTokenResponse. + + '{0}' not a valid MIME boundary. + '{0}' not a valid MIME boundary. + + + + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + + + + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + + + + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + + + + contentType must be non-zero length string. + contentType must be non-zero length string. + + + + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + + + + MessageVersion '{0}' not supported by MTOM encoder. + MessageVersion '{0}' not supported by MTOM encoder. + + + + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + + + + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + + + + URI specified for MIME part Content-ID cannot be empty. + URI specified for MIME part Content-ID cannot be empty. + + + + Invalid start URI for infoset '{0}'. + Invalid start URI for infoset '{0}'. + + + + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + + + + Content-Type header for MTOM message not found. + Content-Type header for MTOM message not found. + + + + MTOM message not valid. Does not contain correctly formatted content following headers. + MTOM message not valid. Does not contain correctly formatted content following headers. + + + + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + + + + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + + + + MTOM messages must have type '{0}'. + MTOM messages must have type '{0}'. + + + + MTOM messages must have media type '{0}' and media subtype '{1}'. + MTOM messages must have media type '{0}' and media subtype '{1}'. + + + + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + + + + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + + + + MIME part with Content-ID '{0}' not found. + MIME part with Content-ID '{0}' not found. + + + + Content-Type header for root MIME part not found. + Content-Type header for root MIME part not found. + + + + Root MIME part must have media type '{0}' and media subtype '{1}'. + Root MIME part must have media type '{0}' and media subtype '{1}'. + + + + Root MIME part containing infoset not found. + Root MIME part containing infoset not found. + + + + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + + + + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + + + + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + + + + Mandatory attribute '{0}' not found on XOP Include element. + Mandatory attribute '{0}' not found on XOP Include element. + + + + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + + + + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + + The extensions cannot contain an Identity if one is supplied as a constructor argument. Расширения не могут содержать удостоверение, если оно предоставлено как аргумент конструктора. @@ -2157,6 +2377,11 @@ Алгоритм ключа для этого открытого ключа не поддерживается. + + Read not supported on stream '{0}'. + Read not supported on stream '{0}'. + + The channel received an unexpected fault input message while closing. The fault reason given is: '{0}' Во время закрытия канала получено неожиданное входящее сообщение об ошибке. Указанная причина ошибки: "{0}" @@ -2557,6 +2782,11 @@ Не удается добавить EndpointDispatcher к нескольким ChannelDispatcher. + + Error creating a reader for the MTOM message + Error creating a reader for the MTOM message + + Server returned an invalid SOAP Fault. Please see InnerException for more details. Сервер вернул недопустимое сообщение об ошибке SOAP. Дополнительные сведения см. в описании внутреннего исключения. @@ -3332,6 +3562,11 @@ Требование к маркеру содержит непредвиденный тип "{1}" для свойства "{0}". Ожидаемый тип свойства "{2}". + + Seek not supported on stream '{0}'. + Seek not supported on stream '{0}'. + + You cannot Send messages on a channel after CloseOutputSession has been called. Нельзя отправить сообщения по каналу после вызова CloseOutputSession. @@ -4392,6 +4627,16 @@ Сервер не принял запрос на подключение. Возможно, версия протокола WebSocket на клиенте не согласуется с таковой на сервере ("{0}"). + + An internal error has occurred. Overflow on MIME writer buffer. + An internal error has occurred. Overflow on MIME writer buffer. + + + + Write not supported on stream '{0}'. + Write not supported on stream '{0}'. + + The remote endpoint has sent an fault message with an unexpected sequence identifier over a session. The fault may be intended for a different session. The fault reason is: {0} The reliable session was faulted. Удаленная сторона отправила сообщение об ошибке с неожиданным идентификатором последовательности для этого сеанса. Ошибка могла предназначаться для другого сеанса. Причина ошибки: {0} Произошел сбой надежного сеанса. @@ -4462,6 +4707,11 @@ В строке словаря не удается найти значение "{0}". + + Array too small. + Array too small. + + An internal error has occurred. The XML buffer is not in the correct state to perform the operation. Произошла внутренняя ошибка. XML-буфер не находится в нужном состоянии, чтобы выполнить эту операцию. @@ -4472,6 +4722,16 @@ Размер, необходимый для размещения в буфере содержимого XML, превысил квоту буфера. + + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + + + + The characters '{0}' at offset {1} are not a valid BinHex sequence. + The characters '{0}' at offset {1} are not a valid BinHex sequence. + + The value '{0}' cannot be parsed as the type '{1}'. Значение "{0}" не может интерпретироваться как тип "{1}". @@ -4487,6 +4747,21 @@ Отсутствует обязательное значение атрибута xml:lang. + + Line {0}, position {1}. + Line {0}, position {1}. + + + + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + + + + The XmlWriter is closed. + The XmlWriter is closed. + + '{0}' is an invalid XmlNodeType. "{0}" является недопустимым XmlNodeType. diff --git a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.tr.xlf b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.tr.xlf index 44815c269ac..21046612638 100644 --- a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.tr.xlf +++ b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.tr.xlf @@ -1602,6 +1602,11 @@ MaxBufferSize, MaxReceivedMessageSize değerini aşmamalıdır. + + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + + The maximum message size quota for incoming messages ({0}) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. Gelen iletiler için en büyük ileti boyutu kotası ({0}) aşıldı. Kotayı artırmak için, ilgili bağlama öğesinde MaxReceivedMessageSize özelliğini kullanın. @@ -1762,6 +1767,71 @@ Ağdan alınan XML ile ilgili bir sorun var. Daha fazla ayrıntı için iç özel duruma bakın. + + Invalid MIME content-type header encountered on read. + Invalid MIME content-type header encountered on read. + + + + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + + + + Content stream can be retrieved from MIME message only once. + Content stream can be retrieved from MIME message only once. + + + + '{0}' MIME header is specified multiple times. + '{0}' MIME header is specified multiple times. + + + + Malformed header. + Malformed header. + + + + Reset called on MIME header reader before end of file. + Reset called on MIME header reader before end of file. + + + + Unexpected end of file. + Unexpected end of file. + + + + Invalid mime-version header encountered on read. + Invalid mime-version header encountered on read. + + + + Cannot call Close on MIME writer in state '{0}'. + Cannot call Close on MIME writer in state '{0}'. + + + + MIME writer cannot write content in state '{0}'. + MIME writer cannot write content in state '{0}'. + + + + MIME writer cannot write MIME header in state '{0}'. + MIME writer cannot write MIME header in state '{0}'. + + + + MIME writer cannot start new MIME part in state '{0}'. + MIME writer cannot start new MIME part in state '{0}'. + + + + MIME writer cannot start preface in '{0}' state. + MIME writer cannot start preface in '{0}' state. + + The incoming message was signed with a token which was different from what used to encrypt the body. This was not expected. Gelen ileti, gövdeyi şifrelemek için kullanılandan farklı bir belirteçle imzalanmıştı. Bu beklenmeyen bir durumdu. @@ -1817,6 +1887,156 @@ Alınan RequestSecurityTokenResponseCollection birden fazla RequestSecurityTokenResponse öğesi içeriyor. Yalnızca bir RequestSecurityTokenResponse öğesi bekleniyordu. + + '{0}' not a valid MIME boundary. + '{0}' not a valid MIME boundary. + + + + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + + + + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + + + + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + + + + contentType must be non-zero length string. + contentType must be non-zero length string. + + + + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + + + + MessageVersion '{0}' not supported by MTOM encoder. + MessageVersion '{0}' not supported by MTOM encoder. + + + + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + + + + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + + + + URI specified for MIME part Content-ID cannot be empty. + URI specified for MIME part Content-ID cannot be empty. + + + + Invalid start URI for infoset '{0}'. + Invalid start URI for infoset '{0}'. + + + + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + + + + Content-Type header for MTOM message not found. + Content-Type header for MTOM message not found. + + + + MTOM message not valid. Does not contain correctly formatted content following headers. + MTOM message not valid. Does not contain correctly formatted content following headers. + + + + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + + + + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + + + + MTOM messages must have type '{0}'. + MTOM messages must have type '{0}'. + + + + MTOM messages must have media type '{0}' and media subtype '{1}'. + MTOM messages must have media type '{0}' and media subtype '{1}'. + + + + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + + + + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + + + + MIME part with Content-ID '{0}' not found. + MIME part with Content-ID '{0}' not found. + + + + Content-Type header for root MIME part not found. + Content-Type header for root MIME part not found. + + + + Root MIME part must have media type '{0}' and media subtype '{1}'. + Root MIME part must have media type '{0}' and media subtype '{1}'. + + + + Root MIME part containing infoset not found. + Root MIME part containing infoset not found. + + + + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + + + + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + + + + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + + + + Mandatory attribute '{0}' not found on XOP Include element. + Mandatory attribute '{0}' not found on XOP Include element. + + + + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + + + + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + + The extensions cannot contain an Identity if one is supplied as a constructor argument. Oluşturucu bağımsız değişkeni olarak bir tane sağlandığı takdirde, uzantılar Identity bulunduramaz. @@ -2157,6 +2377,11 @@ Bu ortak anahtar için anahtar algoritması desteklenmiyor. + + Read not supported on stream '{0}'. + Read not supported on stream '{0}'. + + The channel received an unexpected fault input message while closing. The fault reason given is: '{0}' Kanal kapatılırken beklenmeyen bir hatalı giriş iletisi aldı. Verilen hata nedeni: '{0}' @@ -2557,6 +2782,11 @@ EndpointDispatcher öğesi, birden çok ChannelDispatcher içine eklenemiyor. + + Error creating a reader for the MTOM message + Error creating a reader for the MTOM message + + Server returned an invalid SOAP Fault. Please see InnerException for more details. Sunucu, geçersiz bir SOAP Hatası döndürdü. Ayrıntılar için InnerException öğesine bakın. @@ -3332,6 +3562,11 @@ Belirteç gereksiniminin '{0}' özelliği için beklenmeyen bir '{1}' türü var. Beklenen özellik türü: '{2}'. + + Seek not supported on stream '{0}'. + Seek not supported on stream '{0}'. + + You cannot Send messages on a channel after CloseOutputSession has been called. CloseOutputSession çağrıldıktan sonra, bir kanalda ileti Gönderemezsiniz. @@ -4392,6 +4627,16 @@ Sunucu, bağlantı isteğini kabul etmedi. İstemciniz üzerindeki WebSocket protokol sürümü, sunucudaki ('{0}') ile eşleşmiyor olabilir. + + An internal error has occurred. Overflow on MIME writer buffer. + An internal error has occurred. Overflow on MIME writer buffer. + + + + Write not supported on stream '{0}'. + Write not supported on stream '{0}'. + + The remote endpoint has sent an fault message with an unexpected sequence identifier over a session. The fault may be intended for a different session. The fault reason is: {0} The reliable session was faulted. Uzak bitiş noktası bir oturumda beklenmeyen bir sıra tanımlayıcısıyla bir hata iletisi gönderdi. Hata başka bir oturum için gönderilmiş olabilir. Hata nedeni: {0} Güvenilir oturum hatayla sonlandırıldı. @@ -4462,6 +4707,11 @@ Sözlük dizesinde '{0}' değeri bulunamıyor. + + Array too small. + Array too small. + + An internal error has occurred. The XML buffer is not in the correct state to perform the operation. Bir iç hata oluştu. XML arabelleği bu işlemi gerçekleştirmek için doğru durumda değil. @@ -4472,6 +4722,16 @@ XML içeriğini ara belleğe almak için gerekli olan boyut, ara bellek kotasını aştı. + + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + + + + The characters '{0}' at offset {1} are not a valid BinHex sequence. + The characters '{0}' at offset {1} are not a valid BinHex sequence. + + The value '{0}' cannot be parsed as the type '{1}'. '{0}' değeri, '{1}' türü olarak ayrıştırılamaz. @@ -4487,6 +4747,21 @@ Gereken xml:lang öznitelik değeri eksik. + + Line {0}, position {1}. + Line {0}, position {1}. + + + + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + + + + The XmlWriter is closed. + The XmlWriter is closed. + + '{0}' is an invalid XmlNodeType. '{0}', geçersiz bir XmlNodeType. diff --git a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.zh-Hans.xlf b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.zh-Hans.xlf index ffb22f01e1a..1d77a9f6ed8 100644 --- a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.zh-Hans.xlf @@ -1602,6 +1602,11 @@ MaxBufferSize 不得超过 MaxReceivedMessageSize。 + + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + + The maximum message size quota for incoming messages ({0}) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. 已超过传入消息({0})的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性。 @@ -1762,6 +1767,71 @@ 从网络接收的 XML 存在问题。有关详细信息,请参见内部异常。 + + Invalid MIME content-type header encountered on read. + Invalid MIME content-type header encountered on read. + + + + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + + + + Content stream can be retrieved from MIME message only once. + Content stream can be retrieved from MIME message only once. + + + + '{0}' MIME header is specified multiple times. + '{0}' MIME header is specified multiple times. + + + + Malformed header. + Malformed header. + + + + Reset called on MIME header reader before end of file. + Reset called on MIME header reader before end of file. + + + + Unexpected end of file. + Unexpected end of file. + + + + Invalid mime-version header encountered on read. + Invalid mime-version header encountered on read. + + + + Cannot call Close on MIME writer in state '{0}'. + Cannot call Close on MIME writer in state '{0}'. + + + + MIME writer cannot write content in state '{0}'. + MIME writer cannot write content in state '{0}'. + + + + MIME writer cannot write MIME header in state '{0}'. + MIME writer cannot write MIME header in state '{0}'. + + + + MIME writer cannot start new MIME part in state '{0}'. + MIME writer cannot start new MIME part in state '{0}'. + + + + MIME writer cannot start preface in '{0}' state. + MIME writer cannot start preface in '{0}' state. + + The incoming message was signed with a token which was different from what used to encrypt the body. This was not expected. 用于签名传入消息的标记不同于用于加密正文的标记。这是不允许的。 @@ -1817,6 +1887,156 @@ 收到的 RequestSecurityTokenResponseCollection 具有多个 RequestSecurityTokenResponse 元素。只需要一个 RequestSecurityTokenResponse 元素。 + + '{0}' not a valid MIME boundary. + '{0}' not a valid MIME boundary. + + + + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + + + + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + + + + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + + + + contentType must be non-zero length string. + contentType must be non-zero length string. + + + + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + + + + MessageVersion '{0}' not supported by MTOM encoder. + MessageVersion '{0}' not supported by MTOM encoder. + + + + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + + + + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + + + + URI specified for MIME part Content-ID cannot be empty. + URI specified for MIME part Content-ID cannot be empty. + + + + Invalid start URI for infoset '{0}'. + Invalid start URI for infoset '{0}'. + + + + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + + + + Content-Type header for MTOM message not found. + Content-Type header for MTOM message not found. + + + + MTOM message not valid. Does not contain correctly formatted content following headers. + MTOM message not valid. Does not contain correctly formatted content following headers. + + + + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + + + + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + + + + MTOM messages must have type '{0}'. + MTOM messages must have type '{0}'. + + + + MTOM messages must have media type '{0}' and media subtype '{1}'. + MTOM messages must have media type '{0}' and media subtype '{1}'. + + + + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + + + + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + + + + MIME part with Content-ID '{0}' not found. + MIME part with Content-ID '{0}' not found. + + + + Content-Type header for root MIME part not found. + Content-Type header for root MIME part not found. + + + + Root MIME part must have media type '{0}' and media subtype '{1}'. + Root MIME part must have media type '{0}' and media subtype '{1}'. + + + + Root MIME part containing infoset not found. + Root MIME part containing infoset not found. + + + + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + + + + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + + + + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + + + + Mandatory attribute '{0}' not found on XOP Include element. + Mandatory attribute '{0}' not found on XOP Include element. + + + + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + + + + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + + The extensions cannot contain an Identity if one is supplied as a constructor argument. 如果标识已作为构造函数参数提供,则扩展不能再包含它。 @@ -2157,6 +2377,11 @@ 不支持此公钥的密钥算法。 + + Read not supported on stream '{0}'. + Read not supported on stream '{0}'. + + The channel received an unexpected fault input message while closing. The fault reason given is: '{0}' 通道在关闭时接收到意外的错误输入消息。给出的错误原因为:“{0}” @@ -2557,6 +2782,11 @@ 无法将 EndpointDispatcher 添加到多个 ChannelDispatcher。 + + Error creating a reader for the MTOM message + Error creating a reader for the MTOM message + + Server returned an invalid SOAP Fault. Please see InnerException for more details. 服务器返回无效的 SOAP 错误。有关详细信息,请参见 InnerException。 @@ -3332,6 +3562,11 @@ 令牌要求对于属性“{0}”具有意外类型“{1}”。预期的属性类型为“{2}”。 + + Seek not supported on stream '{0}'. + Seek not supported on stream '{0}'. + + You cannot Send messages on a channel after CloseOutputSession has been called. 调用 CloseOutputSession 以后,无法在通道上发送消息。 @@ -4392,6 +4627,16 @@ 服务器不接受连接请求。有可能是因为客户端上 WebSocket 协议的版本与服务器上该协议的版本({0})不匹配。 + + An internal error has occurred. Overflow on MIME writer buffer. + An internal error has occurred. Overflow on MIME writer buffer. + + + + Write not supported on stream '{0}'. + Write not supported on stream '{0}'. + + The remote endpoint has sent an fault message with an unexpected sequence identifier over a session. The fault may be intended for a different session. The fault reason is: {0} The reliable session was faulted. 远程终结点息通过会话发送了一条带有意外序列标识符的错误消。该错误可能是用于其他会话的。错误原因是: {0} 可靠会话出错。 @@ -4462,6 +4707,11 @@ 在字典字符串中找不到“{0}”值。 + + Array too small. + Array too small. + + An internal error has occurred. The XML buffer is not in the correct state to perform the operation. 发生内部错误。XML 缓冲区未处于正确状态,无法执行操作。 @@ -4472,6 +4722,16 @@ 缓冲处理 XML 内容所需的大小超出了缓冲区配额。 + + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + + + + The characters '{0}' at offset {1} are not a valid BinHex sequence. + The characters '{0}' at offset {1} are not a valid BinHex sequence. + + The value '{0}' cannot be parsed as the type '{1}'. 不能将值“{0}”作为类型“{1}”来分析。 @@ -4487,6 +4747,21 @@ 缺少所需的 xml:lang 特性值。 + + Line {0}, position {1}. + Line {0}, position {1}. + + + + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + + + + The XmlWriter is closed. + The XmlWriter is closed. + + '{0}' is an invalid XmlNodeType. “{0}”是无效的 XmlNodeType。 diff --git a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.zh-Hant.xlf b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.zh-Hant.xlf index d17b34d0d4a..14142847f2b 100644 --- a/src/System.Private.ServiceModel/src/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/System.Private.ServiceModel/src/Resources/xlf/Strings.zh-Hant.xlf @@ -1602,6 +1602,11 @@ MaxBufferSize 不可超過 MaxReceivedMessageSize。 + + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + The number of MIME parts in the MTOM message exceeded the current quota '{0}'. To increase the quota, change the '{1}' setting in the AppSettings section of the configuration file. + + The maximum message size quota for incoming messages ({0}) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. 已超出內送郵件 ({0}) 的訊息大小配額上限。若要增加此配額,請利用適當繫結元素上的 MaxReceivedMessageSize 屬性。 @@ -1762,6 +1767,71 @@ 從網路接收的 XML 發生問題。如需詳細資訊,請參閱內部例外狀況。 + + Invalid MIME content-type header encountered on read. + Invalid MIME content-type header encountered on read. + + + + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + Character '{0}' (hexadecimal value 0x{1}) not valid in MIME header. + + + + Content stream can be retrieved from MIME message only once. + Content stream can be retrieved from MIME message only once. + + + + '{0}' MIME header is specified multiple times. + '{0}' MIME header is specified multiple times. + + + + Malformed header. + Malformed header. + + + + Reset called on MIME header reader before end of file. + Reset called on MIME header reader before end of file. + + + + Unexpected end of file. + Unexpected end of file. + + + + Invalid mime-version header encountered on read. + Invalid mime-version header encountered on read. + + + + Cannot call Close on MIME writer in state '{0}'. + Cannot call Close on MIME writer in state '{0}'. + + + + MIME writer cannot write content in state '{0}'. + MIME writer cannot write content in state '{0}'. + + + + MIME writer cannot write MIME header in state '{0}'. + MIME writer cannot write MIME header in state '{0}'. + + + + MIME writer cannot start new MIME part in state '{0}'. + MIME writer cannot start new MIME part in state '{0}'. + + + + MIME writer cannot start preface in '{0}' state. + MIME writer cannot start preface in '{0}' state. + + The incoming message was signed with a token which was different from what used to encrypt the body. This was not expected. 簽署傳入訊息的權杖與用來加密本文的權杖不同。此為非預期狀況。 @@ -1817,6 +1887,156 @@ RequestSecurityTokenResponseCollection 收到多個 RequestSecurityTokenResponse 元素。僅能有一個 RequestSecurityTokenResponse 元素。 + + '{0}' not a valid MIME boundary. + '{0}' not a valid MIME boundary. + + + + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + The maximum buffer size ({0}) has been exceeded while reading MTOM data. This quota may be increased by changing the maxBufferSize setting used when creating the MTOM reader. + + + + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + Content-Transfer-Encoding header with value '{0}' must be present for binary part. + + + + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + '{0}' Content-Transfer-Encoding not supported for infoset. Must be one of '{1}', '{2}', or '{3}'. + + + + contentType must be non-zero length string. + contentType must be non-zero length string. + + + + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + XML data contained in MTOM messages must not contain element with name '{0}' from namespace '{1}'. + + + + MessageVersion '{0}' not supported by MTOM encoder. + MessageVersion '{0}' not supported by MTOM encoder. + + + + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + The 'maximum size in bytes' quota ({0}) has been exceeded while writing MTOM data. This quota may be increased by changing the maxSizeInBytes setting used when creating the MTOM writer. + + + + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + Invalid URI '{0}' specified for MIME part Content-ID is not conformant cid URI. + + + + URI specified for MIME part Content-ID cannot be empty. + URI specified for MIME part Content-ID cannot be empty. + + + + Invalid start URI for infoset '{0}'. + Invalid start URI for infoset '{0}'. + + + + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + Content-Transfer-Encoding '{0}' not supported for binary part. Must be '{1}'. + + + + Content-Type header for MTOM message not found. + Content-Type header for MTOM message not found. + + + + MTOM message not valid. Does not contain correctly formatted content following headers. + MTOM message not valid. Does not contain correctly formatted content following headers. + + + + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + MTOM message not valid. One or more MIME parts in the message does not contain correctly formatted content and/or boundary string. + + + + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + '{0}' not a valid MIME version. MTOM messages must have MIME version '{1}'. + + + + MTOM messages must have type '{0}'. + MTOM messages must have type '{0}'. + + + + MTOM messages must have media type '{0}' and media subtype '{1}'. + MTOM messages must have media type '{0}' and media subtype '{1}'. + + + + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + MTOM messages must have non-zero length '{0}' parameter in Content-Type header. + + + + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + MTOM message not valid. Infoset references MIME part with Content-ID '{0}' more than once. + + + + MIME part with Content-ID '{0}' not found. + MIME part with Content-ID '{0}' not found. + + + + Content-Type header for root MIME part not found. + Content-Type header for root MIME part not found. + + + + Root MIME part must have media type '{0}' and media subtype '{1}'. + Root MIME part must have media type '{0}' and media subtype '{1}'. + + + + Root MIME part containing infoset not found. + Root MIME part containing infoset not found. + + + + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + Root MIME part must contain non-zero length value for '{0}' parameter in Content-Type header. + + + + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + Unexpected charset '{0}' found in root MIME part. Expecting '{1}'. + + + + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + Unexpected type '{0}' found in root MIME part. Message header specifies '{1}'. + + + + Mandatory attribute '{0}' not found on XOP Include element. + Mandatory attribute '{0}' not found on XOP Include element. + + + + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + XOP Include element has invalid attribute '{0}' from XOP namespace '{1}'. + + + + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + XOP Include element has invalid child element '{0}' from XOP namespace '{1}'. + + The extensions cannot contain an Identity if one is supplied as a constructor argument. 延伸模組不可包含提供作為建構函式引數的身分識別。 @@ -2157,6 +2377,11 @@ 不支援此公開金鑰的金鑰演算法。 + + Read not supported on stream '{0}'. + Read not supported on stream '{0}'. + + The channel received an unexpected fault input message while closing. The fault reason given is: '{0}' 通道在關閉時,收到非預期的錯誤輸入訊息。提供的錯誤原因為: '{0}' @@ -2557,6 +2782,11 @@ 無法將 EndpointDispatcher 新增至一個以上的 ChannelDispatcher。 + + Error creating a reader for the MTOM message + Error creating a reader for the MTOM message + + Server returned an invalid SOAP Fault. Please see InnerException for more details. 伺服器傳回無效的 SOAP 錯誤。如需詳細資訊,請參閱 InnerException。 @@ -3332,6 +3562,11 @@ 權杖需求的屬性 '{0}' 出現非預期的類型 '{1}'。屬性類型應為 '{2}'。 + + Seek not supported on stream '{0}'. + Seek not supported on stream '{0}'. + + You cannot Send messages on a channel after CloseOutputSession has been called. 呼叫 CloseOutputSession 之後,無法在通道上傳送訊息。 @@ -4392,6 +4627,16 @@ 伺服器未接受連線要求。可能是用戶端的 WebSocket 通訊協定版本與伺服器的版本 ('{0}') 不符。 + + An internal error has occurred. Overflow on MIME writer buffer. + An internal error has occurred. Overflow on MIME writer buffer. + + + + Write not supported on stream '{0}'. + Write not supported on stream '{0}'. + + The remote endpoint has sent an fault message with an unexpected sequence identifier over a session. The fault may be intended for a different session. The fault reason is: {0} The reliable session was faulted. 遠端端點已在工作階段上傳送具有不正確順序識別項的錯誤訊息。可能是其他工作階段的錯誤。錯誤原因: {0} 可靠工作階段發生錯誤。 @@ -4462,6 +4707,11 @@ 在字典字串中找不到 '{0}' 值。 + + Array too small. + Array too small. + + An internal error has occurred. The XML buffer is not in the correct state to perform the operation. 發生內部錯誤。XML 緩衝區的狀態不正確,無法執行該作業。 @@ -4472,6 +4722,16 @@ 用以緩衝 XML 內容所需的大小超過緩衝區配額。 + + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + BinHex sequence length ({0}) not valid. Must be a multiple of 2. + + + + The characters '{0}' at offset {1} are not a valid BinHex sequence. + The characters '{0}' at offset {1} are not a valid BinHex sequence. + + The value '{0}' cannot be parsed as the type '{1}'. 值 '{0}' 無法剖析為類型 '{1}'。 @@ -4487,6 +4747,21 @@ 必要的 xml:lang 屬性值已遺失。 + + Line {0}, position {1}. + Line {0}, position {1}. + + + + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + The maximum string content length quota ({0}) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. + + + + The XmlWriter is closed. + The XmlWriter is closed. + + '{0}' is an invalid XmlNodeType. '{0}' 是無效的 XmlNodeType。 diff --git a/src/System.Private.ServiceModel/src/System.Private.ServiceModel.csproj b/src/System.Private.ServiceModel/src/System.Private.ServiceModel.csproj index 617604fe7e4..2c8c19277a9 100644 --- a/src/System.Private.ServiceModel/src/System.Private.ServiceModel.csproj +++ b/src/System.Private.ServiceModel/src/System.Private.ServiceModel.csproj @@ -50,23 +50,18 @@ - - - - + + + + - + - +   False   $(AssemblyName).rd.xml diff --git a/src/System.Private.ServiceModel/src/System/ServiceModel/BasicHttpBinding.cs b/src/System.Private.ServiceModel/src/System/ServiceModel/BasicHttpBinding.cs index dd0c9f1f282..fa7277cf852 100644 --- a/src/System.Private.ServiceModel/src/System/ServiceModel/BasicHttpBinding.cs +++ b/src/System.Private.ServiceModel/src/System/ServiceModel/BasicHttpBinding.cs @@ -25,7 +25,7 @@ public BasicHttpBinding(BasicHttpSecurityMode securityMode) _basicHttpSecurity.Mode = securityMode; } - internal WSMessageEncoding MessageEncoding { get; set; } = BasicHttpBindingDefaults.MessageEncoding; + public WSMessageEncoding MessageEncoding { get; set; } = BasicHttpBindingDefaults.MessageEncoding; public BasicHttpSecurity Security { @@ -74,11 +74,17 @@ public override BindingElementCollection CreateBindingElements() { bindingElements.Add(wsSecurity); } - // add encoding + // add encoding (text or mtom) + WSMessageEncodingHelper.SyncUpEncodingBindingElementProperties(TextMessageEncodingBindingElement, MtomMessageEncodingBindingElement); if (MessageEncoding == WSMessageEncoding.Text) { bindingElements.Add(TextMessageEncodingBindingElement); } + else if (MessageEncoding == WSMessageEncoding.Mtom) + { + bindingElements.Add(MtomMessageEncodingBindingElement); + } + // add transport (http or https) bindingElements.Add(GetTransport()); diff --git a/src/System.Private.ServiceModel/src/System/ServiceModel/BasicHttpsBinding.cs b/src/System.Private.ServiceModel/src/System/ServiceModel/BasicHttpsBinding.cs index c43c7e4c963..b25695224cb 100644 --- a/src/System.Private.ServiceModel/src/System/ServiceModel/BasicHttpsBinding.cs +++ b/src/System.Private.ServiceModel/src/System/ServiceModel/BasicHttpsBinding.cs @@ -20,7 +20,7 @@ public BasicHttpsBinding(BasicHttpsSecurityMode securityMode) _basicHttpsSecurity.Mode = securityMode; } - internal WSMessageEncoding MessageEncoding { get; set; } = BasicHttpBindingDefaults.MessageEncoding; + public WSMessageEncoding MessageEncoding { get; set; } = BasicHttpBindingDefaults.MessageEncoding; public BasicHttpsSecurity Security { @@ -73,15 +73,21 @@ public override BindingElementCollection CreateBindingElements() { bindingElements.Add(wsSecurity); } - // add encoding + // add encoding (text or mtom) + WSMessageEncodingHelper.SyncUpEncodingBindingElementProperties(TextMessageEncodingBindingElement, MtomMessageEncodingBindingElement); if (MessageEncoding == WSMessageEncoding.Text) { bindingElements.Add(TextMessageEncodingBindingElement); } + else if (MessageEncoding == WSMessageEncoding.Mtom) + { + bindingElements.Add(MtomMessageEncodingBindingElement); + } + // add transport (http or https) bindingElements.Add(GetTransport()); return bindingElements.Clone(); } } -} \ No newline at end of file +} diff --git a/src/System.Private.ServiceModel/src/System/ServiceModel/Channels/MessageEncoder.cs b/src/System.Private.ServiceModel/src/System/ServiceModel/Channels/MessageEncoder.cs index 84d3cc52d9a..1f52ca5de6e 100644 --- a/src/System.Private.ServiceModel/src/System/ServiceModel/Channels/MessageEncoder.cs +++ b/src/System.Private.ServiceModel/src/System/ServiceModel/Channels/MessageEncoder.cs @@ -14,6 +14,8 @@ namespace System.ServiceModel.Channels { public abstract class MessageEncoder { + private string _traceSourceString; + public abstract string ContentType { get; } public abstract string MediaType { get; } @@ -244,5 +246,15 @@ internal void ThrowIfMismatchedMessageVersion(Message message) message); } } + + internal string GetTraceSourceString() + { + if (_traceSourceString == null) + { + _traceSourceString = Runtime.Diagnostics.DiagnosticTraceBase.CreateDefaultSourceString(this); + } + + return _traceSourceString; + } } } diff --git a/src/System.Private.ServiceModel/src/System/ServiceModel/Channels/MtomMessageEncoder.cs b/src/System.Private.ServiceModel/src/System/ServiceModel/Channels/MtomMessageEncoder.cs new file mode 100644 index 00000000000..ebc4c5efcfa --- /dev/null +++ b/src/System.Private.ServiceModel/src/System/ServiceModel/Channels/MtomMessageEncoder.cs @@ -0,0 +1,687 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Globalization; +using System.IO; +using System.Runtime; +using System.Runtime.Diagnostics; +using System.ServiceModel.Description; +using System.ServiceModel.Diagnostics; +using System.Text; +using System.Threading.Tasks; +using System.Xml; + +namespace System.ServiceModel.Channels +{ + internal class MtomMessageEncoderFactory : MessageEncoderFactory + { + private MessageVersion _messageVersion; + private Encoding _writeEncoding; + private int _maxReadPoolSize; + private int _maxWritePoolSize; + private int _maxBufferSize; + private XmlDictionaryReaderQuotas _readerQuotas; + + // Pools used by MtomMessageEncoder + private const int MaxPooledXmlReadersPerMessage = 2; + private object _thisLock; + private OnXmlDictionaryReaderClose _onStreamedReaderClose; + // Double-checked locking pattern requires volatile for read/write synchronization + private volatile SynchronizedPool _streamedWriterPool; + private volatile SynchronizedPool _streamedReaderPool; + private volatile SynchronizedPool _bufferedReaderPool; + private volatile SynchronizedPool _bufferedWriterPool; + private volatile SynchronizedPool _recycledStatePool; + + public MtomMessageEncoderFactory(MessageVersion version, Encoding writeEncoding, int maxReadPoolSize, int maxWritePoolSize, int maxBufferSize, XmlDictionaryReaderQuotas quotas) + { + _messageVersion = version; + _writeEncoding = writeEncoding; + _maxReadPoolSize = maxReadPoolSize; + _maxWritePoolSize = maxWritePoolSize; + _maxBufferSize = maxBufferSize; + _readerQuotas = quotas; + _thisLock = new object(); + _onStreamedReaderClose = new OnXmlDictionaryReaderClose(ReturnStreamedReader); + if (version.Envelope == EnvelopeVersion.Soap12) + { + ContentEncodingMap = TextMessageEncoderFactory.Soap12Content; + } + else if (version.Envelope == EnvelopeVersion.Soap11) + { + ContentEncodingMap = TextMessageEncoderFactory.Soap11Content; + } + else + { + Fx.Assert("Invalid MessageVersion"); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Invalid MessageVersion"))); + } + } + + public override MessageEncoder Encoder => new MtomMessageEncoder(_messageVersion, _writeEncoding, _maxReadPoolSize, _maxWritePoolSize, _maxBufferSize, _readerQuotas, this); + + public override MessageVersion MessageVersion => _messageVersion; + + public int MaxWritePoolSize => _maxWritePoolSize; + + public int MaxReadPoolSize => _maxReadPoolSize; + + public XmlDictionaryReaderQuotas ReaderQuotas => _readerQuotas; + + public int MaxBufferSize => _maxBufferSize; + + internal TextMessageEncoderFactory.ContentEncoding[] ContentEncodingMap { get; } + + internal XmlDictionaryWriter TakeStreamedWriter(Stream stream, string startInfo, string boundary, string startUri, bool writeMessageHeaders) + { + if (_streamedWriterPool == null) + { + lock (_thisLock) + { + if (_streamedWriterPool == null) + { + _streamedWriterPool = new SynchronizedPool(MaxWritePoolSize); + } + } + } + XmlDictionaryWriter xmlWriter = _streamedWriterPool.Take(); + if (xmlWriter == null) + { + xmlWriter = XmlMtomWriter.Create(stream, _writeEncoding, int.MaxValue, startInfo, boundary, startUri, writeMessageHeaders, false); + if (WcfEventSource.Instance.WritePoolMissIsEnabled()) + { + WcfEventSource.Instance.WritePoolMiss(xmlWriter.GetType().Name); + } + } + else + { + ((IXmlMtomWriterInitializer)xmlWriter).SetOutput(stream, _writeEncoding, int.MaxValue, startInfo, boundary, startUri, writeMessageHeaders, false); + } + return xmlWriter; + } + + internal void ReturnStreamedWriter(XmlDictionaryWriter xmlWriter) + { + xmlWriter.Close(); + _streamedWriterPool.Return(xmlWriter); + } + + internal MtomMessageEncoder.MtomBufferedMessageWriter TakeBufferedWriter(MtomMessageEncoder messageEncoder) + { + if (_bufferedWriterPool == null) + { + lock (_thisLock) + { + if (_bufferedWriterPool == null) + { + _bufferedWriterPool = new SynchronizedPool(MaxWritePoolSize); + } + } + } + + MtomMessageEncoder.MtomBufferedMessageWriter messageWriter = _bufferedWriterPool.Take(); + if (messageWriter == null) + { + messageWriter = new MtomMessageEncoder.MtomBufferedMessageWriter(messageEncoder); + if (WcfEventSource.Instance.WritePoolMissIsEnabled()) + { + WcfEventSource.Instance.WritePoolMiss(messageWriter.GetType().Name); + } + } + return messageWriter; + } + + internal void ReturnMessageWriter(MtomMessageEncoder.MtomBufferedMessageWriter messageWriter) + { + _bufferedWriterPool.Return(messageWriter); + } + + internal MtomMessageEncoder.MtomBufferedMessageData TakeBufferedReader(MtomMessageEncoder messageEncoder) + { + if (_bufferedReaderPool == null) + { + lock (_thisLock) + { + if (_bufferedReaderPool == null) + { + _bufferedReaderPool = new SynchronizedPool(MaxReadPoolSize); + } + } + } + MtomMessageEncoder.MtomBufferedMessageData messageData = _bufferedReaderPool.Take(); + if (messageData == null) + { + messageData = new MtomMessageEncoder.MtomBufferedMessageData(messageEncoder, MaxPooledXmlReadersPerMessage); + if (WcfEventSource.Instance.ReadPoolMissIsEnabled()) + { + WcfEventSource.Instance.ReadPoolMiss(messageData.GetType().Name); + } + } + return messageData; + } + + internal void ReturnBufferedData(MtomMessageEncoder.MtomBufferedMessageData messageData) + { + _bufferedReaderPool.Return(messageData); + } + + internal XmlReader TakeStreamedReader(Stream stream, string contentType, bool isMtomContentType) + { + if (_streamedReaderPool == null) + { + lock (_thisLock) + { + if (_streamedReaderPool == null) + { + _streamedReaderPool = new SynchronizedPool(MaxReadPoolSize); + } + } + } + XmlDictionaryReader xmlReader = _streamedReaderPool.Take(); + try + { + if (contentType == null || isMtomContentType) + { + if (xmlReader != null && xmlReader is IXmlMtomReaderInitializer) + { + ((IXmlMtomReaderInitializer)xmlReader).SetInput(stream, MtomMessageEncoderFactory.GetSupportedEncodings(), contentType, ReaderQuotas, MaxBufferSize, _onStreamedReaderClose); + } + else + { + xmlReader = XmlMtomReader.Create(stream, MtomMessageEncoderFactory.GetSupportedEncodings(), contentType, ReaderQuotas, MaxBufferSize, _onStreamedReaderClose); + if (WcfEventSource.Instance.ReadPoolMissIsEnabled()) + { + WcfEventSource.Instance.ReadPoolMiss(xmlReader.GetType().Name); + } + } + } + else + { + if (xmlReader != null && xmlReader is IXmlTextReaderInitializer) + { + ((IXmlTextReaderInitializer)xmlReader).SetInput(stream, TextMessageEncoderFactory.GetEncodingFromContentType(contentType, ContentEncodingMap), ReaderQuotas, _onStreamedReaderClose); + } + else + { + xmlReader = XmlDictionaryReader.CreateTextReader(stream, TextMessageEncoderFactory.GetEncodingFromContentType(contentType, ContentEncodingMap), ReaderQuotas, _onStreamedReaderClose); + if (WcfEventSource.Instance.ReadPoolMissIsEnabled()) + { + WcfEventSource.Instance.ReadPoolMiss(xmlReader.GetType().Name); + } + } + } + } + catch (FormatException fe) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException( + SR.SFxErrorCreatingMtomReader, fe)); + } + catch (XmlException xe) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException( + SR.SFxErrorCreatingMtomReader, xe)); + } + + return xmlReader; + } + + internal void ReturnStreamedReader(XmlDictionaryReader xmlReader) + { + _streamedReaderPool.Return(xmlReader); + } + + internal SynchronizedPool RecycledStatePool + { + get + { + if (_recycledStatePool == null) + { + lock (_thisLock) + { + if (_recycledStatePool == null) + { + _recycledStatePool = new SynchronizedPool(MaxReadPoolSize); + } + } + } + return _recycledStatePool; + } + } + + public static Encoding[] GetSupportedEncodings() + { + Encoding[] supported = TextEncoderDefaults.SupportedEncodings; + Encoding[] enc = new Encoding[supported.Length]; + Array.Copy(supported, enc, supported.Length); + return enc; + } + + } + + // Some notes: + // The Encoding passed in is used for the SOAP envelope + internal class MtomMessageEncoder : MessageEncoder, ITraceSourceStringProvider + { + private Encoding _writeEncoding; + private string _contentType; + private string _boundary; + private MessageVersion _version; + private static UriGenerator s_mimeBoundaryGenerator; + private XmlDictionaryReaderQuotas _bufferedReadReaderQuotas; + + private MtomMessageEncoderFactory _factory; + private const string MtomMediaType = "multipart/related"; + private const string MtomContentType = MtomMediaType + "; type=\"application/xop+xml\""; + private const string MtomStartUri = NamingHelper.DefaultNamespace + "0"; + + public MtomMessageEncoder(MessageVersion version, Encoding writeEncoding, int maxReadPoolSize, int maxWritePoolSize, int maxBufferSize, XmlDictionaryReaderQuotas quotas, MtomMessageEncoderFactory factory) + { + if (version == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(version)); + if (writeEncoding == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(writeEncoding)); + + _factory = factory; + TextEncoderDefaults.ValidateEncoding(writeEncoding); + _writeEncoding = writeEncoding; + + MaxReadPoolSize = maxReadPoolSize; + MaxWritePoolSize = maxWritePoolSize; + + ReaderQuotas = new XmlDictionaryReaderQuotas(); + quotas.CopyTo(ReaderQuotas); + + _bufferedReadReaderQuotas = EncoderHelpers.GetBufferedReadQuotas(ReaderQuotas); + MaxBufferSize = maxBufferSize; + _version = version; + _contentType = GetContentType(out _boundary); + } + + private static UriGenerator MimeBoundaryGenerator + { + get + { + if (s_mimeBoundaryGenerator == null) + s_mimeBoundaryGenerator = new UriGenerator("uuid", "+"); + return s_mimeBoundaryGenerator; + } + } + + public override string ContentType => _contentType; + + public int MaxWritePoolSize { get; } + + public int MaxReadPoolSize { get; } + + public XmlDictionaryReaderQuotas ReaderQuotas { get; } + + public int MaxBufferSize { get; } + + public override string MediaType => MtomMediaType; + + public override MessageVersion MessageVersion => _version; + + internal bool IsMTOMContentType(string contentType) + { + // check for MTOM contentType: multipart/related; type=\"application/xop+xml\" + return IsContentTypeSupported(contentType, ContentType, MediaType); + } + + internal bool IsTextContentType(string contentType) + { + // check for Text contentType: text/xml or application/soap+xml + string textMediaType = TextMessageEncoderFactory.GetMediaType(_version); + string textContentType = TextMessageEncoderFactory.GetContentType(textMediaType, _writeEncoding); + return IsContentTypeSupported(contentType, textContentType, textMediaType); + } + + public override bool IsContentTypeSupported(string contentType) + { + if (contentType == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(contentType))); + return (IsMTOMContentType(contentType) || IsTextContentType(contentType)); + } + + internal override bool IsCharSetSupported(string charSet) + { + if (charSet == null || charSet.Length == 0) + return true; + + Encoding tmp; + return TextEncoderDefaults.TryGetEncoding(charSet, out tmp); + } + + private string GenerateStartInfoString() + { + return (_version.Envelope == EnvelopeVersion.Soap12) ? TextMessageEncoderFactory.Soap12MediaType : TextMessageEncoderFactory.Soap11MediaType; + } + + public override Message ReadMessage(ArraySegment buffer, BufferManager bufferManager, string contentType) + { + if (bufferManager == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(bufferManager)); + + if (contentType == ContentType) + contentType = null; + + if (WcfEventSource.Instance.MtomMessageDecodingStartIsEnabled()) + { + WcfEventSource.Instance.MtomMessageDecodingStart(); + } + + MtomBufferedMessageData messageData = _factory.TakeBufferedReader(this); + messageData._contentType = contentType; + messageData.Open(buffer, bufferManager); + RecycledMessageState messageState = messageData.TakeMessageState(); + if (messageState == null) + messageState = new RecycledMessageState(); + Message message = new BufferedMessage(messageData, messageState); + message.Properties.Encoder = this; + if (MessageLogger.LogMessagesAtTransportLevel) + MessageLogger.LogMessage(ref message, MessageLoggingSource.TransportReceive); + + if (WcfEventSource.Instance.MessageReadByEncoderIsEnabled() && buffer != null) + { + WcfEventSource.Instance.MessageReadByEncoder( + EventTraceActivityHelper.TryExtractActivity(message, true), + buffer.Count, + this); + } + + return message; + } + + public override Message ReadMessage(Stream stream, int maxSizeOfHeaders, string contentType) + { + if (stream == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(stream))); + + if (contentType == ContentType) + contentType = null; + + if (WcfEventSource.Instance.MtomMessageDecodingStartIsEnabled()) + { + WcfEventSource.Instance.MtomMessageDecodingStart(); + } + + XmlReader reader = _factory.TakeStreamedReader(stream, contentType, contentType == null || IsMTOMContentType(contentType)); + Message message = Message.CreateMessage(reader, maxSizeOfHeaders, _version); + message.Properties.Encoder = this; + + if (WcfEventSource.Instance.StreamedMessageReadByEncoderIsEnabled()) + { + WcfEventSource.Instance.StreamedMessageReadByEncoder(EventTraceActivityHelper.TryExtractActivity(message, true)); + } + + if (MessageLogger.LogMessagesAtTransportLevel) + MessageLogger.LogMessage(ref message, MessageLoggingSource.TransportReceive); + return message; + } + + public override ArraySegment WriteMessage(Message message, int maxMessageSize, BufferManager bufferManager, int messageOffset) + { + return WriteMessageInternal(message, maxMessageSize, bufferManager, messageOffset, GenerateStartInfoString(), _boundary, MtomStartUri, writeMessageHeaders: true); + } + + public override Task> WriteMessageAsync(Message message, int maxMessageSize, BufferManager bufferManager, int messageOffset) + { + return Task.FromResult(WriteMessageInternal(message, maxMessageSize, bufferManager, messageOffset, GenerateStartInfoString(), _boundary, MtomStartUri, writeMessageHeaders: true)); + } + + private string GetContentType(out string boundary) + { + string startInfo = GenerateStartInfoString(); + boundary = MimeBoundaryGenerator.Next(); + + return FormatContentType(boundary, startInfo); + } + + internal string FormatContentType(string boundary, string startInfo) + { + return string.Format(CultureInfo.InvariantCulture, + "{0};start=\"<{1}>\";boundary=\"{2}\";start-info=\"{3}\"", + MtomContentType, MtomStartUri, boundary, startInfo); + } + + private ArraySegment WriteMessageInternal(Message message, int maxMessageSize, BufferManager bufferManager, int messageOffset, string startInfo, string boundary, string startUri, bool writeMessageHeaders) + { + if (message == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(message)); + if (bufferManager == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(bufferManager)); + if (maxMessageSize < 0) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(maxMessageSize), maxMessageSize, + SR.ValueMustBeNonNegative)); + if (messageOffset < 0 || messageOffset > maxMessageSize) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(messageOffset), messageOffset, + SR.Format(SR.ValueMustBeInRange, 0, maxMessageSize))); + ThrowIfMismatchedMessageVersion(message); + + EventTraceActivity eventTraceActivity = null; + if (WcfEventSource.Instance.MtomMessageEncodingStartIsEnabled()) + { + eventTraceActivity = EventTraceActivityHelper.TryExtractActivity(message); + WcfEventSource.Instance.MtomMessageEncodingStart(eventTraceActivity); + } + + message.Properties.Encoder = this; + + MtomBufferedMessageWriter messageWriter = _factory.TakeBufferedWriter(this); + messageWriter._startInfo = startInfo; + messageWriter._boundary = boundary; + messageWriter._startUri = startUri; + messageWriter._writeMessageHeaders = writeMessageHeaders; + messageWriter._maxSizeInBytes = maxMessageSize; + ArraySegment messageData = messageWriter.WriteMessage(message, bufferManager, messageOffset, maxMessageSize); + _factory.ReturnMessageWriter(messageWriter); + + if (WcfEventSource.Instance.MessageWrittenByEncoderIsEnabled() && messageData != null) + { + WcfEventSource.Instance.MessageWrittenByEncoder( + eventTraceActivity ?? EventTraceActivityHelper.TryExtractActivity(message), + messageData.Count, + this); + } + + if (MessageLogger.LogMessagesAtTransportLevel) + { + string contentType = null; + if (boundary != null) + contentType = FormatContentType(boundary, startInfo ?? GenerateStartInfoString()); + + XmlDictionaryReader xmlDictionaryReader = XmlMtomReader.Create(messageData.Array, messageData.Offset, messageData.Count, MtomMessageEncoderFactory.GetSupportedEncodings(), contentType, XmlDictionaryReaderQuotas.Max, int.MaxValue, null); + MessageLogger.LogMessage(ref message, xmlDictionaryReader, MessageLoggingSource.TransportSend); + } + + return messageData; + } + + public override void WriteMessage(Message message, Stream stream) + { + WriteMessageAsync(message, stream).WaitForCompletionNoSpin(); + } + + public override Task WriteMessageAsync(Message message, Stream stream) + { + return WriteMessageInternalAsync(message, stream, GenerateStartInfoString(), _boundary, MtomStartUri, writeMessageHeaders: true); + } + + public override IAsyncResult BeginWriteMessage(Message message, Stream stream, AsyncCallback callback, object state) + { + return WriteMessageAsync(message, stream).ToApm(callback, state); + } + + public override void EndWriteMessage(IAsyncResult result) + { + result.ToApmEnd(); + } + + private async Task WriteMessageInternalAsync(Message message, Stream stream, string startInfo, string boundary, string startUri, bool writeMessageHeaders) + { + if (message == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(message))); + if (stream == null) + throw TraceUtility.ThrowHelperError(new ArgumentNullException(nameof(stream)), message); + ThrowIfMismatchedMessageVersion(message); + + EventTraceActivity eventTraceActivity = null; + if (WcfEventSource.Instance.MtomMessageEncodingStartIsEnabled()) + { + eventTraceActivity = EventTraceActivityHelper.TryExtractActivity(message); + WcfEventSource.Instance.MtomMessageEncodingStart(eventTraceActivity); + } + + message.Properties.Encoder = this; + if (MessageLogger.LogMessagesAtTransportLevel) + MessageLogger.LogMessage(ref message, MessageLoggingSource.TransportSend); + XmlDictionaryWriter xmlWriter = _factory.TakeStreamedWriter(stream, startInfo, boundary, startUri, writeMessageHeaders); + if (_writeEncoding.WebName == "utf-8") + { + await message.WriteMessageAsync(xmlWriter); + } + else + { + await xmlWriter.WriteStartDocumentAsync(); + await message.WriteMessageAsync(xmlWriter); + await xmlWriter.WriteEndDocumentAsync(); + } + + await xmlWriter.FlushAsync(); + _factory.ReturnStreamedWriter(xmlWriter); + + if (WcfEventSource.Instance.StreamedMessageWrittenByEncoderIsEnabled()) + { + WcfEventSource.Instance.StreamedMessageWrittenByEncoder(eventTraceActivity ?? EventTraceActivityHelper.TryExtractActivity(message)); + } + } + + string ITraceSourceStringProvider.GetSourceString() + { + return GetTraceSourceString(); + } + + internal class MtomBufferedMessageData : BufferedMessageData + { + private MtomMessageEncoder _messageEncoder; + private Pool _readerPool; + internal string _contentType; + private OnXmlDictionaryReaderClose _onClose; + + public MtomBufferedMessageData(MtomMessageEncoder messageEncoder, int maxReaderPoolSize) + : base(messageEncoder._factory.RecycledStatePool) + { + _messageEncoder = messageEncoder; + _readerPool = new Pool(maxReaderPoolSize); + _onClose = new OnXmlDictionaryReaderClose(OnXmlReaderClosed); + } + + public override MessageEncoder MessageEncoder => _messageEncoder; + + public override XmlDictionaryReaderQuotas Quotas => _messageEncoder._bufferedReadReaderQuotas; + + protected override void OnClosed() + { + _messageEncoder._factory.ReturnBufferedData(this); + } + + protected override XmlDictionaryReader TakeXmlReader() + { + try + { + ArraySegment buffer = Buffer; + + XmlDictionaryReader xmlReader = _readerPool.Take(); + if (_contentType == null || _messageEncoder.IsMTOMContentType(_contentType)) + { + if (xmlReader != null && xmlReader is IXmlMtomReaderInitializer) + { + ((IXmlMtomReaderInitializer)xmlReader).SetInput(buffer.Array, buffer.Offset, buffer.Count, MtomMessageEncoderFactory.GetSupportedEncodings(), _contentType, Quotas, _messageEncoder.MaxBufferSize, _onClose); + } + else + { + xmlReader = XmlMtomReader.Create(buffer.Array, buffer.Offset, buffer.Count, MtomMessageEncoderFactory.GetSupportedEncodings(), _contentType, Quotas, _messageEncoder.MaxBufferSize, _onClose); + if (WcfEventSource.Instance.ReadPoolMissIsEnabled()) + { + WcfEventSource.Instance.ReadPoolMiss(xmlReader.GetType().Name); + } + } + } + else + { + if (xmlReader != null && xmlReader is IXmlTextReaderInitializer) + { + ((IXmlTextReaderInitializer)xmlReader).SetInput(buffer.Array, buffer.Offset, buffer.Count, TextMessageEncoderFactory.GetEncodingFromContentType(_contentType, _messageEncoder._factory.ContentEncodingMap), Quotas, _onClose); + } + else + { + xmlReader = XmlDictionaryReader.CreateTextReader(buffer.Array, buffer.Offset, buffer.Count, TextMessageEncoderFactory.GetEncodingFromContentType(_contentType, _messageEncoder._factory.ContentEncodingMap), Quotas, _onClose); + if (WcfEventSource.Instance.ReadPoolMissIsEnabled()) + { + WcfEventSource.Instance.ReadPoolMiss(xmlReader.GetType().Name); + } + } + } + return xmlReader; + } + catch (FormatException fe) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException( + SR.SFxErrorCreatingMtomReader, fe)); + } + catch (XmlException xe) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException( + SR.SFxErrorCreatingMtomReader, xe)); + } + } + + protected override void ReturnXmlReader(XmlDictionaryReader xmlReader) + { + if (xmlReader != null) + _readerPool.Return(xmlReader); + } + } + + internal class MtomBufferedMessageWriter : BufferedMessageWriter + { + private MtomMessageEncoder _messageEncoder; + internal bool _writeMessageHeaders; + internal string _startInfo; + internal string _startUri; + internal string _boundary; + internal int _maxSizeInBytes = int.MaxValue; + private XmlDictionaryWriter _writer; + + public MtomBufferedMessageWriter(MtomMessageEncoder messageEncoder) + { + _messageEncoder = messageEncoder; + } + + protected override XmlDictionaryWriter TakeXmlWriter(Stream stream) + { + XmlDictionaryWriter returnedWriter = _writer; + if (returnedWriter == null) + { + returnedWriter = XmlMtomWriter.Create(stream, _messageEncoder._writeEncoding, _maxSizeInBytes, _startInfo, _boundary, _startUri, _writeMessageHeaders, false); + } + else + { + _writer = null; + ((IXmlMtomWriterInitializer)returnedWriter).SetOutput(stream, _messageEncoder._writeEncoding, _maxSizeInBytes, _startInfo, _boundary, _startUri, _writeMessageHeaders, false); + } + if (_messageEncoder._writeEncoding.WebName != "utf-8") + returnedWriter.WriteStartDocument(); + return returnedWriter; + } + + protected override void ReturnXmlWriter(XmlDictionaryWriter writer) + { + writer.Close(); + + if (_writer == null) + _writer = writer; + } + } + } +} diff --git a/src/System.Private.ServiceModel/src/System/ServiceModel/Channels/MtomMessageEncodingBindingElement.cs b/src/System.Private.ServiceModel/src/System/ServiceModel/Channels/MtomMessageEncodingBindingElement.cs new file mode 100644 index 00000000000..944e73d9ade --- /dev/null +++ b/src/System.Private.ServiceModel/src/System/ServiceModel/Channels/MtomMessageEncodingBindingElement.cs @@ -0,0 +1,230 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.ComponentModel; +using System.Text; +using System.Xml; + +namespace System.ServiceModel.Channels +{ + public sealed class MtomMessageEncodingBindingElement : MessageEncodingBindingElement + { + int _maxReadPoolSize; + int _maxWritePoolSize; + XmlDictionaryReaderQuotas _readerQuotas; + int _maxBufferSize; + Encoding _writeEncoding; + MessageVersion _messageVersion; + + public MtomMessageEncodingBindingElement() : this(MessageVersion.Default, TextEncoderDefaults.Encoding) { } + + public MtomMessageEncodingBindingElement(MessageVersion messageVersion, Encoding writeEncoding) + { + if (messageVersion == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(messageVersion)); + + if (messageVersion == MessageVersion.None) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.MtomEncoderBadMessageVersion, messageVersion.ToString()), nameof(messageVersion))); + + if (writeEncoding == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(writeEncoding)); + + TextEncoderDefaults.ValidateEncoding(writeEncoding); + _maxReadPoolSize = EncoderDefaults.MaxReadPoolSize; + _maxWritePoolSize = EncoderDefaults.MaxWritePoolSize; + _readerQuotas = new XmlDictionaryReaderQuotas(); + EncoderDefaults.ReaderQuotas.CopyTo(_readerQuotas); + _maxBufferSize = MtomEncoderDefaults.MaxBufferSize; + _messageVersion = messageVersion; + _writeEncoding = writeEncoding; + } + + MtomMessageEncodingBindingElement(MtomMessageEncodingBindingElement elementToBeCloned) + : base(elementToBeCloned) + { + _maxReadPoolSize = elementToBeCloned._maxReadPoolSize; + _maxWritePoolSize = elementToBeCloned._maxWritePoolSize; + _readerQuotas = new XmlDictionaryReaderQuotas(); + elementToBeCloned._readerQuotas.CopyTo(_readerQuotas); + _maxBufferSize = elementToBeCloned._maxBufferSize; + _writeEncoding = elementToBeCloned._writeEncoding; + _messageVersion = elementToBeCloned._messageVersion; + } + + [DefaultValue(EncoderDefaults.MaxReadPoolSize)] + public int MaxReadPoolSize + { + get + { + return _maxReadPoolSize; + } + set + { + if (value <= 0) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(value), value, + SR.ValueMustBePositive)); + } + _maxReadPoolSize = value; + } + } + + [DefaultValue(EncoderDefaults.MaxWritePoolSize)] + public int MaxWritePoolSize + { + get + { + return _maxWritePoolSize; + } + set + { + if (value <= 0) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(value), value, + SR.ValueMustBePositive)); + } + _maxWritePoolSize = value; + } + } + + public XmlDictionaryReaderQuotas ReaderQuotas + { + get + { + return _readerQuotas; + } + } + + [DefaultValue(MtomEncoderDefaults.MaxBufferSize)] + public int MaxBufferSize + { + get + { + return _maxBufferSize; + } + set + { + if (value <= 0) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(value), value, + SR.ValueMustBePositive)); + } + _maxBufferSize = value; + } + } + + public Encoding WriteEncoding + { + get + { + return _writeEncoding; + } + set + { + if (value == null) + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value)); + + TextEncoderDefaults.ValidateEncoding(value); + _writeEncoding = value; + } + } + + public override MessageVersion MessageVersion + { + get + { + return _messageVersion; + } + set + { + if (value == null) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value)); + } + if (value == MessageVersion.None) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.MtomEncoderBadMessageVersion, value.ToString()), nameof(value))); + } + + _messageVersion = value; + } + } + + public override IChannelFactory BuildChannelFactory(BindingContext context) + { + return InternalBuildChannelFactory(context); + } + + public override bool CanBuildChannelFactory(BindingContext context) + { + return InternalCanBuildChannelFactory(context); + } + + public override BindingElement Clone() + { + return new MtomMessageEncodingBindingElement(this); + } + + public override MessageEncoderFactory CreateMessageEncoderFactory() + { + return new MtomMessageEncoderFactory(MessageVersion, WriteEncoding, MaxReadPoolSize, MaxWritePoolSize, MaxBufferSize, ReaderQuotas); + } + + public override T GetProperty(BindingContext context) + { + if (context == null) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(context)); + } + if (typeof(T) == typeof(XmlDictionaryReaderQuotas)) + { + return (T)(object)_readerQuotas; + } + else + { + return base.GetProperty(context); + } + } + + internal override bool CheckEncodingVersion(EnvelopeVersion version) + { + return _messageVersion.Envelope == version; + } + + internal override bool IsMatch(BindingElement b) + { + if (!base.IsMatch(b)) + return false; + MtomMessageEncodingBindingElement mtom = b as MtomMessageEncodingBindingElement; + if (mtom == null) + return false; + if (_maxReadPoolSize != mtom.MaxReadPoolSize) + return false; + if (_maxWritePoolSize != mtom.MaxWritePoolSize) + return false; + + // compare XmlDictionaryReaderQuotas + if (_readerQuotas.MaxStringContentLength != mtom.ReaderQuotas.MaxStringContentLength) + return false; + if (_readerQuotas.MaxArrayLength != mtom.ReaderQuotas.MaxArrayLength) + return false; + if (_readerQuotas.MaxBytesPerRead != mtom.ReaderQuotas.MaxBytesPerRead) + return false; + if (_readerQuotas.MaxDepth != mtom.ReaderQuotas.MaxDepth) + return false; + if (_readerQuotas.MaxNameTableCharCount != mtom.ReaderQuotas.MaxNameTableCharCount) + return false; + + if (_maxBufferSize != mtom.MaxBufferSize) + return false; + + if (WriteEncoding.EncodingName != mtom.WriteEncoding.EncodingName) + return false; + if (!MessageVersion.IsMatch(mtom.MessageVersion)) + return false; + + return true; + } + } +} diff --git a/src/System.Private.ServiceModel/src/System/ServiceModel/Channels/TextMessageEncoder.cs b/src/System.Private.ServiceModel/src/System/ServiceModel/Channels/TextMessageEncoder.cs index d6a0e6beb3b..156cd58d833 100644 --- a/src/System.Private.ServiceModel/src/System/ServiceModel/Channels/TextMessageEncoder.cs +++ b/src/System.Private.ServiceModel/src/System/ServiceModel/Channels/TextMessageEncoder.cs @@ -600,7 +600,6 @@ public override void EndWriteMessage(IAsyncResult result) result.ToApmEnd(); } - private XmlDictionaryWriter TakeStreamedWriter(Stream stream) { return XmlDictionaryWriter.CreateTextWriter(stream, _writeEncoding, false); diff --git a/src/System.Private.ServiceModel/src/System/ServiceModel/Channels/TransportDefaults.cs b/src/System.Private.ServiceModel/src/System/ServiceModel/Channels/TransportDefaults.cs index eb4379ec7a0..bbd25bb9ded 100644 --- a/src/System.Private.ServiceModel/src/System/ServiceModel/Channels/TransportDefaults.cs +++ b/src/System.Private.ServiceModel/src/System/ServiceModel/Channels/TransportDefaults.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. - using System.Net; using System.Net.Security; using System.Net.WebSockets; @@ -17,7 +16,7 @@ namespace System.ServiceModel.Channels // If any of the const's are modified in this file, they must also be modified // on the Internal.ServiceModel.Primitives contract and implementation assemblies. - public static class EncoderDefaults + internal static class EncoderDefaults { public const int MaxReadPoolSize = 64; public const int MaxWritePoolSize = 16; @@ -44,7 +43,7 @@ public static bool IsDefaultReaderQuotas(XmlDictionaryReaderQuotas quotas) } } - public static class TextEncoderDefaults + internal static class TextEncoderDefaults { public static readonly Encoding Encoding = Encoding.GetEncoding(TextEncoderDefaults.EncodingString); public const string EncodingString = "utf-8"; @@ -141,14 +140,19 @@ public CharSetEncoding(string charSet, Encoding enc) } } - public static class BinaryEncoderDefaults + internal static class MtomEncoderDefaults + { + internal const int MaxBufferSize = 65536; + } + + internal static class BinaryEncoderDefaults { public static EnvelopeVersion EnvelopeVersion { get { return EnvelopeVersion.Soap12; } } public static BinaryVersion BinaryVersion { get { return BinaryVersion.Version1; } } public const int MaxSessionSize = 2048; } - public static class TransportDefaults + internal static class TransportDefaults { public const bool ExtractGroupsForWindowsAccounts = SspiSecurityTokenProvider.DefaultExtractWindowsGroupClaims; public const HostNameComparisonMode HostNameComparisonMode = System.ServiceModel.HostNameComparisonMode.Exact; @@ -180,7 +184,7 @@ public static MessageEncoderFactory GetDefaultMessageEncoderFactory() } } - public static class ConnectionOrientedTransportDefaults + internal static class ConnectionOrientedTransportDefaults { public const bool AllowNtlm = SspiSecurityTokenProvider.DefaultAllowNtlm; public const int ConnectionBufferSize = 8192; @@ -216,7 +220,7 @@ public static int GetMaxPendingAccepts() } } - public static class TcpTransportDefaults + internal static class TcpTransportDefaults { public const int ListenBacklogConst = 0; public static TimeSpan ConnectionLeaseTimeout { get { return TimeSpanHelper.FromMinutes(5, TcpTransportDefaults.ConnectionLeaseTimeoutString); } } @@ -232,7 +236,7 @@ public static int GetListenBacklog() } } - public static class ApplicationContainerSettingsDefaults + internal static class ApplicationContainerSettingsDefaults { public const string CurrentUserSessionDefaultString = "CurrentSession"; public const string Session0ServiceSessionString = "ServiceSession"; @@ -285,12 +289,12 @@ internal static MessageEncoderFactory GetDefaultMessageEncoderFactory() } } - public static class NetTcpDefaults + internal static class NetTcpDefaults { public const MessageCredentialType MessageSecurityClientCredentialType = MessageCredentialType.Windows; } - public static class OneWayDefaults + internal static class OneWayDefaults { public static TimeSpan IdleTimeout { get { return TimeSpanHelper.FromMinutes(2, IdleTimeoutString); } } public const string IdleTimeoutString = "00:02:00"; @@ -301,7 +305,7 @@ public static class OneWayDefaults public const bool PacketRoutable = false; } - static class ReliableSessionDefaults + internal static class ReliableSessionDefaults { internal const string AcknowledgementIntervalString = "00:00:00.2"; internal static TimeSpan AcknowledgementInterval { get { return TimeSpanHelper.FromMilliseconds(200, AcknowledgementIntervalString); } } @@ -317,7 +321,7 @@ static class ReliableSessionDefaults internal const string ReliableMessagingVersionString = "WSReliableMessagingFebruary2005"; } - public static class BasicHttpBindingDefaults + internal static class BasicHttpBindingDefaults { public const BasicHttpMessageCredentialType MessageSecurityClientCredentialType = BasicHttpMessageCredentialType.UserName; public const WSMessageEncoding MessageEncoding = WSMessageEncoding.Text; @@ -328,7 +332,7 @@ public static Encoding TextEncoding } } - public static class WebSocketDefaults + internal static class WebSocketDefaults { public const WebSocketTransportUsage TransportUsage = WebSocketTransportUsage.Never; public const bool CreateNotificationOnConnection = false; @@ -346,7 +350,7 @@ public static class WebSocketDefaults public const string WebSocketUpgradeHeaderValue = "websocket"; } - public static class NetHttpBindingDefaults + internal static class NetHttpBindingDefaults { public const NetHttpMessageEncoding MessageEncoding = NetHttpMessageEncoding.Binary; public const WebSocketTransportUsage TransportUsage = WebSocketTransportUsage.WhenDuplex; diff --git a/src/System.Private.ServiceModel/src/System/ServiceModel/Dispatcher/StreamFormatter.cs b/src/System.Private.ServiceModel/src/System/ServiceModel/Dispatcher/StreamFormatter.cs index 71b8ba84b4e..95323112be8 100644 --- a/src/System.Private.ServiceModel/src/System/ServiceModel/Dispatcher/StreamFormatter.cs +++ b/src/System.Private.ServiceModel/src/System/ServiceModel/Dispatcher/StreamFormatter.cs @@ -11,6 +11,7 @@ using System.Threading; using System.Threading.Tasks; using System.Xml; +using BufferedReadStream = System.ServiceModel.Channels.BufferedReadStream; namespace System.ServiceModel.Dispatcher { @@ -111,15 +112,13 @@ private void WriteEndWrapperIfNecessary(XmlDictionaryWriter writer) } } - private Task WriteEndWrapperIfNecessaryAsync(XmlDictionaryWriter writer) + private async Task WriteEndWrapperIfNecessaryAsync(XmlDictionaryWriter writer) { - writer.WriteEndElement(); + await writer.WriteEndElementAsync(); if (WrapperName != null) { - writer.WriteEndElement(); + await writer.WriteEndElementAsync(); } - - return Task.CompletedTask; } internal IAsyncResult BeginSerialize(XmlDictionaryWriter writer, object[] parameters, object returnValue, AsyncCallback callback, object state) diff --git a/src/System.Private.ServiceModel/src/System/ServiceModel/HttpBindingBase.cs b/src/System.Private.ServiceModel/src/System/ServiceModel/HttpBindingBase.cs index afdda4caeb1..74105555c60 100644 --- a/src/System.Private.ServiceModel/src/System/ServiceModel/HttpBindingBase.cs +++ b/src/System.Private.ServiceModel/src/System/ServiceModel/HttpBindingBase.cs @@ -24,6 +24,9 @@ internal HttpBindingBase() TextMessageEncodingBindingElement = new TextMessageEncodingBindingElement(); TextMessageEncodingBindingElement.MessageVersion = MessageVersion.Soap11; + MtomMessageEncodingBindingElement = new MtomMessageEncodingBindingElement(); + MtomMessageEncodingBindingElement.MessageVersion = MessageVersion.Soap11; + _httpsTransport.WebSocketSettings = _httpTransport.WebSocketSettings; } @@ -84,6 +87,7 @@ public int MaxBufferSize { _httpTransport.MaxBufferSize = value; _httpsTransport.MaxBufferSize = value; + MtomMessageEncodingBindingElement.MaxBufferSize = value; } } @@ -148,6 +152,8 @@ public XmlDictionaryReaderQuotas ReaderQuotas } value.CopyTo(TextMessageEncodingBindingElement.ReaderQuotas); + value.CopyTo(MtomMessageEncodingBindingElement.ReaderQuotas); + SetReaderQuotas(value); } } @@ -175,6 +181,7 @@ public Encoding TextEncoding set { TextMessageEncodingBindingElement.WriteEncoding = value; + MtomMessageEncodingBindingElement.WriteEncoding = value; } } @@ -215,6 +222,8 @@ bool IBindingRuntimePreferences.ReceiveSynchronously internal TextMessageEncodingBindingElement TextMessageEncodingBindingElement { get; } + internal MtomMessageEncodingBindingElement MtomMessageEncodingBindingElement { get; } + internal abstract BasicHttpSecurity BasicHttpSecurity { get; diff --git a/src/System.Private.ServiceModel/src/System/ServiceModel/NetHttpBinding.cs b/src/System.Private.ServiceModel/src/System/ServiceModel/NetHttpBinding.cs index af47a5af975..9d4b7b0b05a 100644 --- a/src/System.Private.ServiceModel/src/System/ServiceModel/NetHttpBinding.cs +++ b/src/System.Private.ServiceModel/src/System/ServiceModel/NetHttpBinding.cs @@ -135,7 +135,8 @@ public override BindingElementCollection CreateBindingElements() bindingElements.Add(TextMessageEncodingBindingElement); break; case NetHttpMessageEncoding.Mtom: - throw ExceptionHelper.PlatformNotSupported(SR.Format(SR.UnsupportedBindingProperty, "MessageEncoding", MessageEncoding)); + bindingElements.Add(MtomMessageEncodingBindingElement); + break; default: bindingElements.Add(_binaryMessageEncodingBindingElement); break; @@ -157,22 +158,12 @@ internal override EnvelopeVersion GetEnvelopeVersion() return EnvelopeVersion.Soap12; } - internal override void CheckSettings() - { - base.CheckSettings(); - - // Mtom is not supported. - if (MessageEncoding == NetHttpMessageEncoding.Mtom) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.UnsupportedBindingProperty, "MessageEncoding", MessageEncoding))); - } - } - private void Initialize() { MessageEncoding = NetHttpBindingDefaults.MessageEncoding; _binaryMessageEncodingBindingElement = new BinaryMessageEncodingBindingElement() { MessageVersion = MessageVersion.Soap12WSAddressing10 }; TextMessageEncodingBindingElement.MessageVersion = MessageVersion.Soap12WSAddressing10; + MtomMessageEncodingBindingElement.MessageVersion = MessageVersion.Soap12WSAddressing10; _session = new ReliableSessionBindingElement(); _reliableSession = new OptionalReliableSession(_session); WebSocketSettings.TransportUsage = NetHttpBindingDefaults.TransportUsage; diff --git a/src/System.Private.ServiceModel/src/System/ServiceModel/NetHttpsBinding.cs b/src/System.Private.ServiceModel/src/System/ServiceModel/NetHttpsBinding.cs index 892105d1886..b3bf6df8948 100644 --- a/src/System.Private.ServiceModel/src/System/ServiceModel/NetHttpsBinding.cs +++ b/src/System.Private.ServiceModel/src/System/ServiceModel/NetHttpsBinding.cs @@ -122,7 +122,8 @@ public override BindingElementCollection CreateBindingElements() bindingElements.Add(TextMessageEncodingBindingElement); break; case NetHttpMessageEncoding.Mtom: - throw ExceptionHelper.PlatformNotSupported(SR.Format(SR.UnsupportedBindingProperty, "MessageEncoding", MessageEncoding)); + bindingElements.Add(MtomMessageEncodingBindingElement); + break; default: bindingElements.Add(_binaryMessageEncodingBindingElement); break; @@ -144,22 +145,12 @@ internal override EnvelopeVersion GetEnvelopeVersion() return EnvelopeVersion.Soap12; } - internal override void CheckSettings() - { - base.CheckSettings(); - - // Mtom is not supported. - if (MessageEncoding == NetHttpMessageEncoding.Mtom) - { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.UnsupportedBindingProperty, "MessageEncoding", MessageEncoding))); - } - } - private void Initialize() { MessageEncoding = NetHttpBindingDefaults.MessageEncoding; _binaryMessageEncodingBindingElement = new BinaryMessageEncodingBindingElement() { MessageVersion = MessageVersion.Soap12WSAddressing10 }; TextMessageEncodingBindingElement.MessageVersion = MessageVersion.Soap12WSAddressing10; + MtomMessageEncodingBindingElement.MessageVersion = MessageVersion.Soap12WSAddressing10; _session = new ReliableSessionBindingElement(); _reliableSession = new OptionalReliableSession(_session); InternalWebSocketSettings.TransportUsage = NetHttpBindingDefaults.TransportUsage; diff --git a/src/System.Private.ServiceModel/src/System/ServiceModel/WSHttpBindingBase.cs b/src/System.Private.ServiceModel/src/System/ServiceModel/WSHttpBindingBase.cs index 105e73ef9ab..dae85c447b2 100644 --- a/src/System.Private.ServiceModel/src/System/ServiceModel/WSHttpBindingBase.cs +++ b/src/System.Private.ServiceModel/src/System/ServiceModel/WSHttpBindingBase.cs @@ -12,6 +12,7 @@ public abstract class WSHttpBindingBase : Binding { private OptionalReliableSession _reliableSession; private TextMessageEncodingBindingElement _textEncoding; + private MtomMessageEncodingBindingElement _mtomEncoding; private ReliableSessionBindingElement _session; protected WSHttpBindingBase() @@ -74,9 +75,12 @@ public long MaxReceivedMessageSize } HttpTransport.MaxReceivedMessageSize = value; HttpsTransport.MaxReceivedMessageSize = value; + _mtomEncoding.MaxBufferSize = (int)value; } } + public WSMessageEncoding MessageEncoding { get; set; } + [DefaultValue(HttpTransportDefaults.ProxyAddress)] public Uri ProxyAddress { @@ -99,6 +103,7 @@ public XmlDictionaryReaderQuotas ReaderQuotas } value.CopyTo(_textEncoding.ReaderQuotas); + value.CopyTo(_mtomEncoding.ReaderQuotas); } } @@ -129,6 +134,7 @@ public Text.Encoding TextEncoding set { _textEncoding.WriteEncoding = value; + _mtomEncoding.WriteEncoding = value; } } @@ -154,6 +160,8 @@ private void Initialize() _session = new ReliableSessionBindingElement(true); _textEncoding = new TextMessageEncodingBindingElement(); _textEncoding.MessageVersion = MessageVersion.Soap12WSAddressing10; + _mtomEncoding = new MtomMessageEncodingBindingElement(); + _mtomEncoding.MessageVersion = MessageVersion.Soap12WSAddressing10; _reliableSession = new OptionalReliableSession(_session); } @@ -176,8 +184,16 @@ public override BindingElementCollection CreateBindingElements() bindingElements.Add(wsSecurity); } - // add encoding - bindingElements.Add(_textEncoding); + // add encoding (text or mtom) + WSMessageEncodingHelper.SyncUpEncodingBindingElementProperties(_textEncoding, _mtomEncoding); + if (this.MessageEncoding == WSMessageEncoding.Text) + { + bindingElements.Add(_textEncoding); + } + else if (this.MessageEncoding == WSMessageEncoding.Mtom) + { + bindingElements.Add(_mtomEncoding); + } // add transport (http or https) bindingElements.Add(GetTransport()); diff --git a/src/System.Private.ServiceModel/src/System/ServiceModel/WSMessageEncoding.cs b/src/System.Private.ServiceModel/src/System/ServiceModel/WSMessageEncoding.cs index f3c26eda973..24ba17cdf4f 100644 --- a/src/System.Private.ServiceModel/src/System/ServiceModel/WSMessageEncoding.cs +++ b/src/System.Private.ServiceModel/src/System/ServiceModel/WSMessageEncoding.cs @@ -3,11 +3,14 @@ // See the LICENSE file in the project root for more information. +using System.ServiceModel.Channels; + namespace System.ServiceModel { public enum WSMessageEncoding { Text = 0, + Mtom } internal static class WSMessageEncodingHelper @@ -16,5 +19,13 @@ internal static bool IsDefined(WSMessageEncoding value) { return value == WSMessageEncoding.Text; } + + internal static void SyncUpEncodingBindingElementProperties(TextMessageEncodingBindingElement textEncoding, MtomMessageEncodingBindingElement mtomEncoding) + { + // textEncoding provides the backing store for ReaderQuotas and WriteEncoding, + // we must ensure same values propogate to mtomEncoding + textEncoding.ReaderQuotas.CopyTo(mtomEncoding.ReaderQuotas); + mtomEncoding.WriteEncoding = textEncoding.WriteEncoding; + } } } diff --git a/src/System.Private.ServiceModel/tests/Common/Scenarios/Endpoints.cs b/src/System.Private.ServiceModel/tests/Common/Scenarios/Endpoints.cs index c692c69e699..93c85713519 100644 --- a/src/System.Private.ServiceModel/tests/Common/Scenarios/Endpoints.cs +++ b/src/System.Private.ServiceModel/tests/Common/Scenarios/Endpoints.cs @@ -23,9 +23,14 @@ public static string DefaultCustomHttp_Address get { return GetEndpointAddress("DefaultCustomHttp.svc//default-custom-http"); } } + public static string HttpBaseAddress_Basic_Text + { + get { return GetEndpointAddress("BasicHttp.svc/Text"); } + } + public static string HttpBaseAddress_Basic { - get { return GetEndpointAddress("BasicHttp.svc//Basic"); } + get { return GetEndpointAddress("BasicHttp.svc/"); } } public static string HttpBaseAddress_BasicService1 @@ -46,7 +51,7 @@ public static string HttpBaseAddress_Basic_Soap public static string HttpBaseAddress_NetHttp { - get { return GetEndpointAddress("NetHttp.svc//NetHttp"); } + get { return GetEndpointAddress("NetHttp.svc/"); } } public static string HttpSoap11_Address @@ -159,6 +164,11 @@ public static string ReliableOneWaySession_WSHttp get { return GetEndpointAddress("ReliableSessionOneWayService.svc/WSHttp"); } } + public static string WSHttpBindingBaseAddress + { + get { return GetEndpointAddress("WSHttp.svc/"); } + } + #region WebSocket Addresses public static string HttpBaseAddress_NetHttpWebSockets { @@ -180,44 +190,24 @@ public static string NetHttpDuplexWebSocket_Address get { return GetEndpointAddress("DuplexWebSocket.svc//http-defaultduplexwebsockets", protocol: "ws"); } } - public static string WebSocketHttpDuplexBinaryStreamed_Address - { - get { return GetEndpointAddress("WebSocketHttpDuplexBinaryStreamed.svc//WebSocketHttpDuplexBinaryStreamedResource", protocol: "ws"); } - } - - public static string WebSocketHttpRequestReplyBinaryStreamed_Address - { - get { return GetEndpointAddress("WebSocketHttpRequestReplyBinaryStreamed.svc//WebSocketHttpRequestReplyBinaryStreamedResource", protocol: "ws"); } - } - - public static string WebSocketHttpRequestReplyTextStreamed_Address + public static string WebSocketHttpDuplexStreamed_Address { - get { return GetEndpointAddress("WebSocketHttpRequestReplyTextStreamed.svc//WebSocketHttpRequestReplyTextStreamedResource", protocol: "ws"); } + get { return GetEndpointAddress("WebSocketHttpDuplex.svc/Streamed", protocol: "ws"); } } - public static string WebSocketHttpDuplexTextStreamed_Address + public static string WebSocketHttpRequestReplyStreamed_Address { - get { return GetEndpointAddress("WebSocketHttpDuplexTextStreamed.svc//WebSocketHttpDuplexTextStreamedResource", protocol: "ws"); } + get { return GetEndpointAddress("WebSocketHttpRequestReply.svc/Streamed", protocol: "ws"); } } - public static string WebSocketHttpRequestReplyTextBuffered_Address + public static string WebSocketHttpRequestReplyBuffered_Address { - get { return GetEndpointAddress("WebSocketHttpRequestReplyTextBuffered.svc//WebSocketHttpRequestReplyTextBufferedResource", protocol: "ws"); } + get { return GetEndpointAddress("WebSocketHttpRequestReply.svc/Buffered", protocol: "ws"); } } - public static string WebSocketHttpRequestReplyBinaryBuffered_Address + public static string WebSocketHttpDuplexBuffered_Address { - get { return GetEndpointAddress("WebSocketHttpRequestReplyBinaryBuffered.svc//WebSocketHttpRequestReplyBinaryBufferedResource", protocol: "ws"); } - } - - public static string WebSocketHttpDuplexTextBuffered_Address - { - get { return GetEndpointAddress("WebSocketHttpDuplexTextBuffered.svc//WebSocketHttpDuplexTextBufferedResource", protocol: "ws"); } - } - - public static string WebSocketHttpDuplexBinaryBuffered_Address - { - get { return GetEndpointAddress("WebSocketHttpDuplexBinaryBuffered.svc//WebSocketHttpDuplexBinaryBufferedResource", protocol: "ws"); } + get { return GetEndpointAddress("WebSocketHttpDuplex.svc/Buffered", protocol: "ws"); } } public static string WebSocketHttpVerifyWebSocketsUsed_Address @@ -336,11 +326,19 @@ public static string Http_WindowsAuth_Address } } + public static string Https_DefaultBinding_Address_Text + { + get + { + return GetEndpointAddress("BasicHttps.svc/Text", protocol: "https"); + } + } + public static string Https_DefaultBinding_Address { get { - return GetEndpointAddress("BasicHttps.svc//basicHttps", protocol: "https"); + return GetEndpointAddress("BasicHttps.svc/", protocol: "https"); } } @@ -360,11 +358,19 @@ public static string HttpsSoap12_Address } } + public static string HttpBaseAddress_NetHttps_Binary + { + get + { + return GetEndpointAddress("NetHttps.svc/Binary", protocol: "https"); + } + } + public static string HttpBaseAddress_NetHttps { get { - return GetEndpointAddress("NetHttps.svc//NetHttps", protocol: "https"); + return GetEndpointAddress("NetHttps.svc/", protocol: "https"); } } @@ -457,51 +463,27 @@ public static string Https_SecModeTransWithMessCred_ClientCredTypeIssuedTokenSam } #region Secure WebSocket Addresses - public static string WebSocketHttpsDuplexBinaryStreamed_Address - { - get - { - return GetEndpointAddress("WebSocketHttpsDuplexBinaryStreamed.svc//WebSocketHttpsDuplexBinaryStreamedResource", protocol: "wss"); - } - } - - public static string WebSocketHttpsDuplexTextStreamed_Address - { - get - { - return GetEndpointAddress("WebSocketHttpsDuplexTextStreamed.svc//WebSocketHttpsDuplexTextStreamedResource", protocol: "wss"); - } - } - - public static string WebSocketHttpsRequestReplyBinaryBuffered_Address - { - get - { - return GetEndpointAddress("WebSocketHttpsRequestReplyBinaryBuffered.svc//WebSocketHttpsRequestReplyBinaryBufferedResource", protocol: "wss"); - } - } - - public static string WebSocketHttpsRequestReplyTextBuffered_Address + public static string WebSocketHttpsDuplexStreamed_Address { get { - return GetEndpointAddress("WebSocketHttpsRequestReplyTextBuffered.svc//WebSocketHttpsRequestReplyTextBufferedResource", protocol: "wss"); + return GetEndpointAddress("WebSocketHttpsDuplex.svc/Streamed", protocol: "wss"); } } - public static string WebSocketHttpsDuplexBinaryBuffered_Address + public static string WebSocketHttpsRequestReplyBuffered_Address { get { - return GetEndpointAddress("WebSocketHttpsDuplexBinaryBuffered.svc//WebSocketHttpsDuplexBinaryBufferedResource", protocol: "wss"); + return GetEndpointAddress("WebSocketHttpsRequestReply.svc/Buffered", protocol: "wss"); } } - public static string WebSocketHttpsDuplexTextBuffered_Address + public static string WebSocketHttpsDuplexBuffered_Address { get { - return GetEndpointAddress("WebSocketHttpsDuplexTextBuffered.svc//WebSocketHttpsDuplexTextBufferedResource", protocol: "wss"); + return GetEndpointAddress("WebSocketHttpsDuplex.svc/Buffered", protocol: "wss"); } } #endregion Secure WebSocket Addresses diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Binding/Http/BasicHttpBindingTests.4.0.0.cs b/src/System.Private.ServiceModel/tests/Scenarios/Binding/Http/BasicHttpBindingTests.4.0.0.cs index be2a4c3ce29..d754b1e36ca 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Binding/Http/BasicHttpBindingTests.4.0.0.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Binding/Http/BasicHttpBindingTests.4.0.0.cs @@ -13,20 +13,24 @@ public static class Binding_Http_BasicHttpBindingTests { - [WcfFact] + [WcfTheory] + [InlineData(WSMessageEncoding.Text)] + [InlineData(WSMessageEncoding.Mtom)] [OuterLoop] - public static void DefaultSettings_Echo_RoundTrips_String() + public static void DefaultSettings_Echo_RoundTrips_String(WSMessageEncoding messageEncoding) { ChannelFactory factory = null; IWcfService serviceProxy = null; string testString = "Hello"; - Binding binding = null; + BasicHttpBinding binding = null; try { // *** SETUP *** \\ binding = new BasicHttpBinding(BasicHttpSecurityMode.None); - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + binding.MessageEncoding = messageEncoding; + + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic + Enum.GetName(typeof(WSMessageEncoding), messageEncoding))); serviceProxy = factory.CreateChannel(); // *** EXECUTE *** \\ @@ -46,24 +50,27 @@ public static void DefaultSettings_Echo_RoundTrips_String() } } - [WcfFact] + [WcfTheory] + [InlineData(WSMessageEncoding.Text)] + [InlineData(WSMessageEncoding.Mtom)] [OuterLoop] - public static void HttpKeepAliveDisabled_Echo_RoundTrips_True() + public static void HttpKeepAliveDisabled_Echo_RoundTrips_True(WSMessageEncoding messageEncoding) { ChannelFactory factory = null; IWcfService serviceProxy = null; - Binding binding = null; + BasicHttpBinding binding = null; CustomBinding customBinding = null; try { // *** SETUP *** \\ binding = new BasicHttpBinding(BasicHttpSecurityMode.None); + binding.MessageEncoding = messageEncoding; customBinding = new CustomBinding(binding); var httpElement = customBinding.Elements.Find(); httpElement.KeepAliveEnabled = false; - factory = new ChannelFactory(customBinding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(customBinding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic + Enum.GetName(typeof(WSMessageEncoding), messageEncoding))); serviceProxy = factory.CreateChannel(); // *** EXECUTE *** \\ @@ -83,20 +90,23 @@ public static void HttpKeepAliveDisabled_Echo_RoundTrips_True() } } - [WcfFact] + [WcfTheory] + [InlineData(WSMessageEncoding.Text)] + [InlineData(WSMessageEncoding.Mtom)] [OuterLoop] - public static void HttpMessageHandlerFactory_Success() + public static void HttpMessageHandlerFactory_Success(WSMessageEncoding messageEncoding) { ChannelFactory factory = null; IWcfService serviceProxy = null; string testString = "Hello"; - Binding binding = null; + BasicHttpBinding binding = null; try { // *** SETUP *** \\ binding = new BasicHttpBinding(BasicHttpSecurityMode.None); - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + binding.MessageEncoding = messageEncoding; + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic + Enum.GetName(typeof(WSMessageEncoding), messageEncoding))); var handlerFactoryBehavior = new HttpMessageHandlerBehavior(); bool handlerCalled = false; handlerFactoryBehavior.OnSendingAsync = (message, token) => @@ -125,21 +135,24 @@ public static void HttpMessageHandlerFactory_Success() } } - [WcfFact] + [WcfTheory] + [InlineData(WSMessageEncoding.Text)] + [InlineData(WSMessageEncoding.Mtom)] [OuterLoop] - public static void HttpMessageHandlerFactory_ModifyContent_Success() + public static void HttpMessageHandlerFactory_ModifyContent_Success(WSMessageEncoding messageEncoding) { ChannelFactory factory = null; IWcfService serviceProxy = null; string testString = "Hello"; string substituteString = "World"; - Binding binding = null; + BasicHttpBinding binding = null; try { // *** SETUP *** \\ binding = new BasicHttpBinding(BasicHttpSecurityMode.None); - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + binding.MessageEncoding = messageEncoding; + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic + Enum.GetName(typeof(WSMessageEncoding), messageEncoding))); var handlerFactoryBehavior = new HttpMessageHandlerBehavior(); handlerFactoryBehavior.OnSendingAsync = (message, token) => { @@ -179,9 +192,11 @@ public static void HttpMessageHandlerFactory_ModifyContent_Success() } } - [WcfFact] + [WcfTheory] + [InlineData(WSMessageEncoding.Text)] + [InlineData(WSMessageEncoding.Mtom)] [OuterLoop] - public static void HttpExpect100Continue_AnonymousAuth_False() + public static void HttpExpect100Continue_AnonymousAuth_False(WSMessageEncoding messageEncoding) { ChannelFactory factory = null; IWcfService serviceProxy = null; @@ -191,8 +206,9 @@ public static void HttpExpect100Continue_AnonymousAuth_False() { // *** SETUP *** \\ binding = new BasicHttpBinding(BasicHttpSecurityMode.None); + binding.MessageEncoding = messageEncoding; - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic + Enum.GetName(typeof(WSMessageEncoding), messageEncoding))); serviceProxy = factory.CreateChannel(); // *** EXECUTE *** \\ @@ -214,9 +230,11 @@ public static void HttpExpect100Continue_AnonymousAuth_False() } } - [WcfFact] + [WcfTheory] + [InlineData(WSMessageEncoding.Text)] + [InlineData(WSMessageEncoding.Mtom)] [OuterLoop] - public static void MultiValue_UserAgent_Success() + public static void MultiValue_UserAgent_Success(WSMessageEncoding messageEncoding) { ChannelFactory factory = null; IWcfService serviceProxy = null; @@ -228,8 +246,9 @@ public static void MultiValue_UserAgent_Success() { // *** SETUP *** \\ binding = new BasicHttpBinding(BasicHttpSecurityMode.None); + binding.MessageEncoding = messageEncoding; - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic + Enum.GetName(typeof(WSMessageEncoding), messageEncoding))); serviceProxy = factory.CreateChannel(); // *** EXECUTE *** \\ @@ -273,7 +292,7 @@ public static void Invalid_UserAgent_Failure() // *** SETUP *** \\ binding = new BasicHttpBinding(BasicHttpSecurityMode.None); - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy = factory.CreateChannel(); // *** EXECUTE *** \\ diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Binding/Http/NetHttpBindingTests.4.0.0.cs b/src/System.Private.ServiceModel/tests/Scenarios/Binding/Http/NetHttpBindingTests.4.0.0.cs index cae8c19ffc3..defec06f556 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Binding/Http/NetHttpBindingTests.4.0.0.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Binding/Http/NetHttpBindingTests.4.0.0.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. - using System; using System.ServiceModel; using Infrastructure.Common; @@ -10,9 +9,12 @@ public static class Binding_Http_NetHttpBindingTests { - [WcfFact] + [WcfTheory] + [InlineData(NetHttpMessageEncoding.Binary)] + [InlineData(NetHttpMessageEncoding.Text)] + [InlineData(NetHttpMessageEncoding.Mtom)] [OuterLoop] - public static void DefaultSettings_Echo_RoundTrips_String() + public static void DefaultSettings_Echo_RoundTrips_String(NetHttpMessageEncoding messageEncoding) { string testString = "Hello"; ChannelFactory factory = null; @@ -22,7 +24,8 @@ public static void DefaultSettings_Echo_RoundTrips_String() { // *** SETUP *** \\ NetHttpBinding binding = new NetHttpBinding(); - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_NetHttp)); + binding.MessageEncoding = messageEncoding; + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_NetHttp + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding))); serviceProxy = factory.CreateChannel(); // *** EXECUTE *** \\ @@ -42,4 +45,4 @@ public static void DefaultSettings_Echo_RoundTrips_String() ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy, factory); } } -} \ No newline at end of file +} diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Binding/Http/NetHttpsBindingTests.4.1.0.cs b/src/System.Private.ServiceModel/tests/Scenarios/Binding/Http/NetHttpsBindingTests.4.1.0.cs index ae08b13847b..a689b64e4a4 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Binding/Http/NetHttpsBindingTests.4.1.0.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Binding/Http/NetHttpsBindingTests.4.1.0.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. - using System; using System.ServiceModel; using Infrastructure.Common; @@ -10,12 +9,15 @@ public class Binding_Http_NetHttpsBindingTests : ConditionalWcfTest { - [WcfFact] + [WcfTheory] + [InlineData(NetHttpMessageEncoding.Binary)] + [InlineData(NetHttpMessageEncoding.Text)] + [InlineData(NetHttpMessageEncoding.Mtom)] [Issue(3572, OS = OSID.OSX_10_14)] [Condition(nameof(Root_Certificate_Installed), nameof(SSL_Available))] [OuterLoop] - public static void DefaultCtor_NetHttps_Echo_RoundTrips_String() + public static void DefaultCtor_NetHttps_Echo_RoundTrips_String(NetHttpMessageEncoding messageEncoding) { string testString = "Hello"; ChannelFactory factory = null; @@ -25,7 +27,8 @@ public static void DefaultCtor_NetHttps_Echo_RoundTrips_String() { // *** SETUP *** \\ NetHttpsBinding netHttpsBinding = new NetHttpsBinding(); - factory = new ChannelFactory(netHttpsBinding, new EndpointAddress(Endpoints.HttpBaseAddress_NetHttps)); + netHttpsBinding.MessageEncoding = messageEncoding; + factory = new ChannelFactory(netHttpsBinding, new EndpointAddress(Endpoints.HttpBaseAddress_NetHttps + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding))); serviceProxy = factory.CreateChannel(); // *** EXECUTE *** \\ @@ -62,7 +65,7 @@ public static void TransportWithMessageCredential_NotSupported_NetHttps() { // *** SETUP *** \\ NetHttpsBinding netHttpsBinding = new NetHttpsBinding(BasicHttpsSecurityMode.TransportWithMessageCredential); - factory = new ChannelFactory(netHttpsBinding, new EndpointAddress(Endpoints.HttpBaseAddress_NetHttps)); + factory = new ChannelFactory(netHttpsBinding, new EndpointAddress(Endpoints.HttpBaseAddress_NetHttps_Binary)); serviceProxy = factory.CreateChannel(); // *** EXECUTE *** \\ @@ -91,7 +94,7 @@ public static void NonDefaultCtor_NetHttps_Echo_RoundTrips_String() { // *** SETUP *** \\ NetHttpsBinding netHttpsBinding = new NetHttpsBinding(BasicHttpsSecurityMode.Transport); - factory = new ChannelFactory(netHttpsBinding, new EndpointAddress(Endpoints.HttpBaseAddress_NetHttps)); + factory = new ChannelFactory(netHttpsBinding, new EndpointAddress(Endpoints.HttpBaseAddress_NetHttps_Binary)); serviceProxy = factory.CreateChannel(); // *** EXECUTE *** \\ diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Binding/Http/OperationContextTests.cs b/src/System.Private.ServiceModel/tests/Scenarios/Binding/Http/OperationContextTests.cs index 6d583998801..ceeb0e3a86f 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Binding/Http/OperationContextTests.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Binding/Http/OperationContextTests.cs @@ -38,7 +38,7 @@ public static async Task OperationContextLegacyBehavior() bool asyncFlowDisabled = AppContext.TryGetSwitch("System.ServiceModel.OperationContext.DisableAsyncFlow", out bool switchEnabled) && switchEnabled; Assert.True(asyncFlowDisabled, "Async flow of Operation Context isn't disabled"); var binding = new BasicHttpBinding(BasicHttpSecurityMode.None); - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy = factory.CreateChannel(); ((IClientChannel)serviceProxy).Open(); Assert.Null(OperationContext.Current); diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Binding/Http/WSHttpBindingTests.cs b/src/System.Private.ServiceModel/tests/Scenarios/Binding/Http/WSHttpBindingTests.cs new file mode 100644 index 00000000000..a92cee4dbac --- /dev/null +++ b/src/System.Private.ServiceModel/tests/Scenarios/Binding/Http/WSHttpBindingTests.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.ServiceModel; +using System.Text; +using Infrastructure.Common; +using Xunit; + +public static class Binding_Http_WSHttpBindingTests +{ + [WcfTheory] + [InlineData(WSMessageEncoding.Text)] + [InlineData(WSMessageEncoding.Mtom)] + [OuterLoop] + public static void DefaultSettings_Echo_RoundTrips_String(WSMessageEncoding messageEncoding) + { + ChannelFactory factory = null; + IWcfService serviceProxy = null; + string testString = "Hello"; + WSHttpBinding binding = null; + + try + { + // *** SETUP *** \\ + binding = new WSHttpBinding(SecurityMode.None); + binding.MessageEncoding = messageEncoding; + + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.WSHttpBindingBaseAddress + Enum.GetName(typeof(WSMessageEncoding), messageEncoding))); + serviceProxy = factory.CreateChannel(); + + // *** EXECUTE *** \\ + string result = serviceProxy.Echo(testString); + + // *** VALIDATE *** \\ + Assert.True(result == testString, String.Format("Error: expected response from service: '{0}' Actual was: '{1}'", testString, result)); + + // *** CLEANUP *** \\ + factory.Close(); + ((ICommunicationObject)serviceProxy).Close(); + } + finally + { + // *** ENSURE CLEANUP *** \\ + ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy, factory); + } + } +} + diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Client/ChannelLayer/RequestReplyChannelShapeTests.4.0.0.cs b/src/System.Private.ServiceModel/tests/Scenarios/Client/ChannelLayer/RequestReplyChannelShapeTests.4.0.0.cs index 54baf5cbdaa..5488ea319f1 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Client/ChannelLayer/RequestReplyChannelShapeTests.4.0.0.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Client/ChannelLayer/RequestReplyChannelShapeTests.4.0.0.cs @@ -37,7 +37,7 @@ public static void IRequestChannel_Http_BasicHttpBinding() factory.Open(); // Create the channel. - channel = factory.CreateChannel(new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + channel = factory.CreateChannel(new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); channel.Open(); // Create the Message object to send to the service. @@ -143,7 +143,7 @@ public static void IRequestChannel_Async_Http_BasicHttpBinding() Task.Factory.FromAsync(factory.BeginOpen, factory.EndOpen, TaskCreationOptions.None).GetAwaiter().GetResult(); // Create the channel. - channel = factory.CreateChannel(new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + channel = factory.CreateChannel(new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); Task.Factory.FromAsync(channel.BeginOpen, channel.EndOpen, TaskCreationOptions.None).GetAwaiter().GetResult(); // Create the Message object to send to the service. diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Client/ChannelLayer/RequestReplyChannelShapeTests.4.1.0.cs b/src/System.Private.ServiceModel/tests/Scenarios/Client/ChannelLayer/RequestReplyChannelShapeTests.4.1.0.cs index 3eb9e64fd90..28e98514973 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Client/ChannelLayer/RequestReplyChannelShapeTests.4.1.0.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Client/ChannelLayer/RequestReplyChannelShapeTests.4.1.0.cs @@ -36,7 +36,7 @@ public static void IRequestChannel_Https_NetHttpsBinding() factory.Open(); // Create the channel. - channel = factory.CreateChannel(new EndpointAddress(Endpoints.HttpBaseAddress_NetHttps)); + channel = factory.CreateChannel(new EndpointAddress(Endpoints.HttpBaseAddress_NetHttps_Binary)); channel.Open(); // Create the Message object to send to the service. diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Client/ClientBase/ClientBaseTests.4.0.0.cs b/src/System.Private.ServiceModel/tests/Scenarios/Client/ClientBase/ClientBaseTests.4.0.0.cs index 293e7abb132..1257c5ab8eb 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Client/ClientBase/ClientBaseTests.4.0.0.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Client/ClientBase/ClientBaseTests.4.0.0.cs @@ -769,7 +769,7 @@ public static void OperationContextScope_HttpRequestCustomMessageHeader_RoundTri // *** SETUP *** \\ BasicHttpBinding binding = new BasicHttpBinding(); - client = new MyClientBase(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + client = new MyClientBase(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy = client.ChannelFactory.CreateChannel(); using (OperationContextScope scope = new OperationContextScope((IContextChannel)serviceProxy)) diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Client/ClientBase/ClientBaseTests.4.1.0.cs b/src/System.Private.ServiceModel/tests/Scenarios/Client/ClientBase/ClientBaseTests.4.1.0.cs index f988b215553..5a3f7d5c1ae 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Client/ClientBase/ClientBaseTests.4.1.0.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Client/ClientBase/ClientBaseTests.4.1.0.cs @@ -22,7 +22,7 @@ public static void DefaultSettings_Echo_Cookie() { AllowCookies = true }, - new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); IWcfAspNetCompatibleService serviceProxy = factory.CreateChannel(); @@ -32,7 +32,7 @@ public static void DefaultSettings_Echo_Cookie() string cookieName = "cookieName"; string cookieValue = "cookieValue"; string cookieSentOut = string.Format("{0}={1}", cookieName, cookieValue); - cookieManager.CookieContainer.Add(new Uri(Endpoints.HttpBaseAddress_Basic), new System.Net.Cookie(cookieName, cookieValue)); + cookieManager.CookieContainer.Add(new Uri(Endpoints.HttpBaseAddress_Basic_Text), new System.Net.Cookie(cookieName, cookieValue)); try { @@ -59,7 +59,7 @@ public static void DefaultSettings_Echo_Cookie() public static void DefaultSettings_SetCookieOnServerSide() { // *** SETUP *** \\ - Uri uri = new Uri(Endpoints.HttpBaseAddress_Basic); + Uri uri = new Uri(Endpoints.HttpBaseAddress_Basic_Text); var factory = new ChannelFactory( new BasicHttpBinding() { diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Client/ClientBase/DuplexClientBaseTests.4.1.0.cs b/src/System.Private.ServiceModel/tests/Scenarios/Client/ClientBase/DuplexClientBaseTests.4.1.0.cs index aa3739dd660..cb225f8a340 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Client/ClientBase/DuplexClientBaseTests.4.1.0.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Client/ClientBase/DuplexClientBaseTests.4.1.0.cs @@ -27,7 +27,7 @@ public static void DuplexClientBaseOfT_OverHttp_Call_Throws_InvalidOperation() WcfDuplexServiceCallback callbackService = new WcfDuplexServiceCallback(); InstanceContext context = new InstanceContext(callbackService); - duplexService = new MyDuplexClientBase(context, binding, new EndpointAddress(Endpoints.Https_DefaultBinding_Address)); + duplexService = new MyDuplexClientBase(context, binding, new EndpointAddress(Endpoints.Https_DefaultBinding_Address_Text)); // *** EXECUTE *** \\ var exception = Assert.Throws(() => diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Client/ClientBase/MessageInspectorTests.4.4.0.cs b/src/System.Private.ServiceModel/tests/Scenarios/Client/ClientBase/MessageInspectorTests.4.4.0.cs index 2e8770acb06..20e9105b8bf 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Client/ClientBase/MessageInspectorTests.4.4.0.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Client/ClientBase/MessageInspectorTests.4.4.0.cs @@ -29,7 +29,7 @@ public static void MessageInspector_RoundtripCustomHeaders_ComplexType() // *** SETUP *** \\ binding = new BasicHttpBinding((BasicHttpSecurityMode)BasicHttpSecurityMode.None); AuthenticationType authType = AuthenticationType.Live; - EndpointAddress endPoint = new EndpointAddress(Endpoints.HttpBaseAddress_Basic); + EndpointAddress endPoint = new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text); // *** EXECUTE FIRST VARIATION *** \\ @@ -82,7 +82,7 @@ public static void MessageInspector_RoundtripCustomHeaders() AuthenticationType authType = AuthenticationType.None; - EndpointAddress endPoint = new EndpointAddress(Endpoints.HttpBaseAddress_Basic); + EndpointAddress endPoint = new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text); mi_ClientBase_ClientAuth = new MI_ClientBase_ClientAuth(authType.ToString(), accessToken, binding, endPoint); diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Client/ExpectedExceptions/ExpectedExceptionTests.4.0.0.cs b/src/System.Private.ServiceModel/tests/Scenarios/Client/ExpectedExceptions/ExpectedExceptionTests.4.0.0.cs index ac595ae51e5..1746c6cf48d 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Client/ExpectedExceptions/ExpectedExceptionTests.4.0.0.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Client/ExpectedExceptions/ExpectedExceptionTests.4.0.0.cs @@ -29,7 +29,7 @@ public static void NonExistentAction_Throws_ActionNotSupportedException() { // *** SETUP *** \\ binding = new BasicHttpBinding(); - endpointAddress = new EndpointAddress(Endpoints.HttpBaseAddress_Basic); + endpointAddress = new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text); factory = new ChannelFactory(binding, endpointAddress); serviceProxy = factory.CreateChannel(); @@ -70,7 +70,7 @@ public static void SendTimeout_For_Long_Running_Operation_Throws_TimeoutExceptio // *** SETUP *** \\ binding = new BasicHttpBinding(); binding.SendTimeout = TimeSpan.FromMilliseconds(5000); - endpointAddress = new EndpointAddress(Endpoints.HttpBaseAddress_Basic); + endpointAddress = new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text); factory = new ChannelFactory(binding, endpointAddress); serviceProxy = factory.CreateChannel(); watch = new Stopwatch(); @@ -117,7 +117,7 @@ public static void SendTimeout_Zero_Throws_TimeoutException_Immediately() // *** SETUP *** \\ binding = new BasicHttpBinding(); binding.SendTimeout = TimeSpan.FromMilliseconds(0); - endpointAddress = new EndpointAddress(Endpoints.HttpBaseAddress_Basic); + endpointAddress = new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text); factory = new ChannelFactory(binding, endpointAddress); serviceProxy = factory.CreateChannel(); watch = new Stopwatch(); @@ -159,7 +159,7 @@ public static void FaultException_Throws_WithFaultDetail() { // *** SETUP *** \\ binding = new BasicHttpBinding(); - endpointAddress = new EndpointAddress(Endpoints.HttpBaseAddress_Basic); + endpointAddress = new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text); factory = new ChannelFactory(binding, endpointAddress); serviceProxy = factory.CreateChannel(); @@ -194,7 +194,7 @@ public static void UnexpectedException_Throws_FaultException() { // *** SETUP *** \\ binding = new BasicHttpBinding(); - endpointAddress = new EndpointAddress(Endpoints.HttpBaseAddress_Basic); + endpointAddress = new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text); factory = new ChannelFactory(binding, endpointAddress); serviceProxy = factory.CreateChannel(); @@ -256,7 +256,7 @@ public static void Abort_During_Implicit_Open_Closes_Async_Waiters() binding.TransferMode = TransferMode.Streamed; // SendTimeout is the timeout used for implicit opens binding.SendTimeout = TimeSpan.FromMilliseconds(timeoutMs); - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy = factory.CreateChannel(); // Force the implicit open to stall until we have multiple concurrent calls pending. diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Client/ExpectedExceptions/ExpectedExceptionTests.4.1.0.cs b/src/System.Private.ServiceModel/tests/Scenarios/Client/ExpectedExceptions/ExpectedExceptionTests.4.1.0.cs index 87b6158c1e9..16f06638204 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Client/ExpectedExceptions/ExpectedExceptionTests.4.1.0.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Client/ExpectedExceptions/ExpectedExceptionTests.4.1.0.cs @@ -68,7 +68,7 @@ public static void ServiceRestart_Throws_CommunicationException() // We need the Service to create and open a ServiceHost and then give us the endpoint address for it. try { - setupHostFactory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + setupHostFactory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); setupHostServiceProxy = setupHostFactory.CreateChannel(); restartServiceAddress = setupHostServiceProxy.GetRestartServiceEndpoint(); @@ -89,7 +89,7 @@ public static void ServiceRestart_Throws_CommunicationException() // Use Endpoints.HttpBaseAddress_Basic only for the purpose of extracting the Service host name. // Then update 'restartServiceAddress' with it. - string hostName = new Uri(Endpoints.HttpBaseAddress_Basic).Host; + string hostName = new Uri(Endpoints.HttpBaseAddress_Basic_Text).Host; restartServiceAddress = restartServiceAddress.Replace("[HOST]", hostName); // Get the last portion of the restart service url which is a Guid and convert it back to a Guid @@ -150,7 +150,7 @@ public static void ServiceRestart_Throws_CommunicationException() public static void UnknownUrl_Throws_EndpointNotFoundException() { // We need a running service host at the other end but mangle the endpoint suffix - string notFoundUrl = Endpoints.HttpBaseAddress_Basic + "not-an-endpoint"; + string notFoundUrl = Endpoints.HttpBaseAddress_Basic_Text + "not-an-endpoint"; BasicHttpBinding binding = null; ChannelFactory factory = null; EndpointAddress endpointAddress = null; @@ -506,7 +506,7 @@ public static void Abort_During_Implicit_Open_Closes_Sync_Waiters() binding.TransferMode = TransferMode.Streamed; // SendTimeout is the timeout used for implicit opens binding.SendTimeout = TimeSpan.FromMilliseconds(timeoutMs); - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy = factory.CreateChannel(); // Force the implicit open to stall until we have multiple concurrent calls pending. diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Contract/Fault/FaultExceptionTests.4.0.0.cs b/src/System.Private.ServiceModel/tests/Scenarios/Contract/Fault/FaultExceptionTests.4.0.0.cs index eaf9abe1240..7e6d76cb8f0 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Contract/Fault/FaultExceptionTests.4.0.0.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Contract/Fault/FaultExceptionTests.4.0.0.cs @@ -25,8 +25,8 @@ public static void FaultException_Throws_WithFaultDetail() { // *** SETUP *** \\ binding = new BasicHttpBinding(); - endpointAddress = new EndpointAddress(Endpoints.HttpBaseAddress_Basic); - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + endpointAddress = new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy = factory.CreateChannel(); // *** EXECUTE *** \\ @@ -59,7 +59,7 @@ public static void UnexpectedException_Throws_FaultException() { // *** SETUP *** \\ binding = new BasicHttpBinding(); - endpointAddress = new EndpointAddress(Endpoints.HttpBaseAddress_Basic); + endpointAddress = new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text); factory = new ChannelFactory(binding, endpointAddress); serviceProxy = factory.CreateChannel(); @@ -94,7 +94,7 @@ public static void FaultException_Throws_With_Int() { // *** SETUP *** \\ binding = new BasicHttpBinding(); - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy = factory.CreateChannel(); // *** EXECUTE *** \\ @@ -131,7 +131,7 @@ public static void FaultException_MultipleFaultContracts_Throws_WithFaultDetail( { // *** SETUP *** \\ binding = new BasicHttpBinding(); - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy = factory.CreateChannel(); // *** EXECUTE *** \\ @@ -168,7 +168,7 @@ public static void FaultException_MultipleFaultContracts_Throws_WithFaultDetail2 { // *** SETUP *** \\ binding = new BasicHttpBinding(); - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy = factory.CreateChannel(); // *** EXECUTE *** \\ @@ -205,7 +205,7 @@ public static void FaultException_FaultContractAndKnownType_Throws_WithFaultDeta { // *** SETUP *** \\ binding = new BasicHttpBinding(); - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy = factory.CreateChannel(); // *** EXECUTE *** \\ @@ -238,7 +238,7 @@ public static void FaultException_FaultContractAndKnownType_Echo() // *** SETUP *** \\ binding = new BasicHttpBinding(); - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy = factory.CreateChannel(); // *** EXECUTE *** \\ diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Contract/Message/MessageContractCommon.4.1.0.cs b/src/System.Private.ServiceModel/tests/Scenarios/Contract/Message/MessageContractCommon.4.1.0.cs index 60440b4cd64..f4db8c9a718 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Contract/Message/MessageContractCommon.4.1.0.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Contract/Message/MessageContractCommon.4.1.0.cs @@ -45,7 +45,7 @@ public static MyInspector SetupMessageContractTests(out IMessageContract clientP { MyInspector inspector = new MyInspector(); BasicHttpBinding binding = new BasicHttpBinding(); - ChannelFactory factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + ChannelFactory factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); factory.Endpoint.EndpointBehaviors.Add(inspector); clientProxy = factory.CreateChannel(); transaction = new MessageContractTypes.RequestBankingData(); diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Contract/Message/MessageTests.4.0.0.cs b/src/System.Private.ServiceModel/tests/Scenarios/Contract/Message/MessageTests.4.0.0.cs index 73a2ca4ccbe..4bb877304d5 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Contract/Message/MessageTests.4.0.0.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Contract/Message/MessageTests.4.0.0.cs @@ -26,7 +26,7 @@ public static void Custom_Message_RoundTrips() factory.Open(); // Create the channel. - IRequestChannel channel = factory.CreateChannel(new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + IRequestChannel channel = factory.CreateChannel(new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); channel.Open(); // Create the Message object to send to the service. @@ -69,7 +69,7 @@ public static void Echo_With_CustomClientMessageFormatter_RoundTrips_String() { // *** SETUP *** \\ binding = new BasicHttpBinding(BasicHttpSecurityMode.None); - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); string suffix = "_suffix"; var customBehavior = new AppendSuffixToStringBehavior(suffix); diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Contract/Service/ServiceContractTests.4.0.0.cs b/src/System.Private.ServiceModel/tests/Scenarios/Contract/Service/ServiceContractTests.4.0.0.cs index 6be5e945904..0c24b2d8d2d 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Contract/Service/ServiceContractTests.4.0.0.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Contract/Service/ServiceContractTests.4.0.0.cs @@ -301,7 +301,7 @@ public static void BasicHttp_Async_Open_ChannelFactory() // *** SETUP *** \\ binding = new BasicHttpBinding(BasicHttpSecurityMode.None); binding.OpenTimeout = ScenarioTestHelpers.TestTimeout; - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); // *** EXECUTE *** \\ Task t = Task.Factory.FromAsync(factory.BeginOpen, factory.EndOpen, TaskCreationOptions.None); @@ -353,7 +353,7 @@ public static void BasicHttp_Async_Open_Proxy() { // *** SETUP *** \\ binding = new BasicHttpBinding(BasicHttpSecurityMode.None); - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy = factory.CreateChannel(); // *** EXECUTE *** \\ @@ -407,7 +407,7 @@ public static void BasicHttp_Async_Close_ChannelFactory() // *** SETUP *** \\ binding = new BasicHttpBinding(BasicHttpSecurityMode.None); binding.CloseTimeout = ScenarioTestHelpers.TestTimeout; - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy = factory.CreateChannel(); result = serviceProxy.Echo(testString); // force proxy and factory to open as part of setup ((ICommunicationObject)serviceProxy).Close(); // force proxy closed before close factory @@ -456,7 +456,7 @@ public static void BasicHttp_Async_Close_Proxy() { // *** SETUP *** \\ binding = new BasicHttpBinding(BasicHttpSecurityMode.None); - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy = factory.CreateChannel(); serviceProxy.Echo(testString); // force sync open as part of setup diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Contract/Service/ServiceContractTests.4.1.0.cs b/src/System.Private.ServiceModel/tests/Scenarios/Contract/Service/ServiceContractTests.4.1.0.cs index e8fa9f6091f..14a273610fb 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Contract/Service/ServiceContractTests.4.1.0.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Contract/Service/ServiceContractTests.4.1.0.cs @@ -32,7 +32,7 @@ public static void BasicHttp_DefaultSettings_Echo_RoundTrips_String_Buffered() // *** SETUP *** \\ binding = new BasicHttpBinding(BasicHttpSecurityMode.None); binding.TransferMode = TransferMode.Buffered; - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy = factory.CreateChannel(); stream = StringToStream(testString); @@ -69,7 +69,7 @@ public static void BasicHttp_DefaultSettings_Echo_RoundTrips_String_StreamedRequ // *** SETUP *** \\ binding = new BasicHttpBinding(BasicHttpSecurityMode.None); binding.TransferMode = TransferMode.StreamedRequest; - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy = factory.CreateChannel(); stream = StringToStream(testString); @@ -104,7 +104,7 @@ public static void BasicHttp_DefaultSettings_Echo_RoundTrips_String_StreamedResp // *** SETUP *** \\ binding = new BasicHttpBinding(BasicHttpSecurityMode.None); binding.TransferMode = TransferMode.StreamedResponse; - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy = factory.CreateChannel(); // *** EXECUTE *** \\ @@ -140,7 +140,7 @@ public static void BasicHttp_DefaultSettings_Echo_RoundTrips_String_Streamed() // *** SETUP *** \\ binding = new BasicHttpBinding(BasicHttpSecurityMode.None); binding.TransferMode = TransferMode.Streamed; - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy = factory.CreateChannel(); stream = StringToStream(testString); @@ -177,7 +177,7 @@ public static void BasicHttp_DefaultSettings_Echo_RoundTrips_String_Streamed_Asy // *** SETUP *** \\ binding = new BasicHttpBinding(BasicHttpSecurityMode.None); binding.TransferMode = TransferMode.Streamed; - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy = factory.CreateChannel(); stream = StringToStream(testString); @@ -245,7 +245,7 @@ public static void BasicHttp_Streamed_Async_Delayed_And_Aborted_Request_Throws_T binding = new BasicHttpBinding(BasicHttpSecurityMode.None); binding.TransferMode = TransferMode.Streamed; binding.SendTimeout = TimeSpan.FromMilliseconds(sendTimeoutMs); - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy = factory.CreateChannel(); // Create a read stream that will both timeout and then abort the proxy channel when the @@ -307,7 +307,7 @@ public static void BasicHttp_Streamed_Async_Delayed_Request_Throws_TimeoutExcept binding = new BasicHttpBinding(BasicHttpSecurityMode.None); binding.TransferMode = TransferMode.Streamed; binding.SendTimeout = TimeSpan.FromMilliseconds(sendTimeoutMs); - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy = factory.CreateChannel(); // Create a read stream that deliberately times out during the async read during the request. @@ -689,7 +689,7 @@ public static void BasicHttp_Abort_ChannelFactory_Operations_Active() binding = new BasicHttpBinding(BasicHttpSecurityMode.None); binding.CloseTimeout = ScenarioTestHelpers.TestTimeout; binding.SendTimeout = ScenarioTestHelpers.TestTimeout; - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy1 = factory.CreateChannel(); serviceProxy2 = factory.CreateChannel(); @@ -779,7 +779,7 @@ public static void BasicHttp_Close_ChannelFactory_Operations_Active() binding = new BasicHttpBinding(BasicHttpSecurityMode.None); binding.CloseTimeout = ScenarioTestHelpers.TestTimeout; binding.SendTimeout = ScenarioTestHelpers.TestTimeout; - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy1 = factory.CreateChannel(); serviceProxy2 = factory.CreateChannel(); @@ -869,7 +869,7 @@ public static void BasicHttp_Async_Close_ChannelFactory_Operations_Active() binding = new BasicHttpBinding(BasicHttpSecurityMode.None); binding.CloseTimeout = ScenarioTestHelpers.TestTimeout; binding.SendTimeout = ScenarioTestHelpers.TestTimeout; - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy1 = factory.CreateChannel(); serviceProxy2 = factory.CreateChannel(); diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Contract/Service/ServiceKnownTypeTests.4.0.0.cs b/src/System.Private.ServiceModel/tests/Scenarios/Contract/Service/ServiceKnownTypeTests.4.0.0.cs index c48da2c0d31..22ad4530c12 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Contract/Service/ServiceKnownTypeTests.4.0.0.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Contract/Service/ServiceKnownTypeTests.4.0.0.cs @@ -90,7 +90,7 @@ public static void ServiceKnownType_XmlSerializerFormat_TwoOperationsShareKnownT private static ChannelFactory GetChannelFactory() { var binding = new BasicHttpBinding(); - var endpointAddress = new EndpointAddress(Endpoints.HttpBaseAddress_Basic); + var endpointAddress = new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text); var factory = new ChannelFactory(binding, endpointAddress); return factory; } diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Contract/XmlSerializer/XmlSerializerFormatTest.4.0.0.cs b/src/System.Private.ServiceModel/tests/Scenarios/Contract/XmlSerializer/XmlSerializerFormatTest.4.0.0.cs index caaee4fbbab..6868bd563bd 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Contract/XmlSerializer/XmlSerializerFormatTest.4.0.0.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Contract/XmlSerializer/XmlSerializerFormatTest.4.0.0.cs @@ -11,7 +11,7 @@ public static partial class XmlSerializerFormatTests { - private static readonly string s_basicEndpointAddress = Endpoints.HttpBaseAddress_Basic; + private static readonly string s_basicEndpointAddress = Endpoints.HttpBaseAddress_Basic_Text; [WcfFact] [OuterLoop] diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Contract/XmlSerializer/XmlSerializerFormatTest.4.1.0.cs b/src/System.Private.ServiceModel/tests/Scenarios/Contract/XmlSerializer/XmlSerializerFormatTest.4.1.0.cs index f8448bd7ca1..07b3d7ee7cf 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Contract/XmlSerializer/XmlSerializerFormatTest.4.1.0.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Contract/XmlSerializer/XmlSerializerFormatTest.4.1.0.cs @@ -16,7 +16,7 @@ public static void MessageHeader_ResponseTypeWithUsesMessageHeaderAttribute() { // *** SETUP *** \\ var binding = new BasicHttpBinding(); - var endpointAddress = new EndpointAddress(Endpoints.HttpBaseAddress_Basic); + var endpointAddress = new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text); var factory = new ChannelFactory(binding, endpointAddress); IXmlMessageContarctTestService serviceProxy = factory.CreateChannel(); var input = new XmlMessageContractTestRequest("1"); @@ -43,7 +43,7 @@ public static void MessageHeader_RequestTypeWithUsesMessageHeaderAttribute() { // *** SETUP *** \\ var binding = new BasicHttpBinding(); - var endpointAddress = new EndpointAddress(Endpoints.HttpBaseAddress_Basic); + var endpointAddress = new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text); var factory = new ChannelFactory(binding, endpointAddress); IXmlMessageContarctTestService serviceProxy = factory.CreateChannel(); var input = new XmlMessageContractTestRequestWithMessageHeader("1"); @@ -70,7 +70,7 @@ public static void OperationContextScope_HttpRequestCustomMessageHeader_RoundTri { // *** SETUP *** \\ BasicHttpBinding binding = new BasicHttpBinding(); - MyClientBase client = new MyClientBase(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + MyClientBase client = new MyClientBase(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); IWcfServiceXml_OperationContext serviceProxy = client.ChannelFactory.CreateChannel(); string customHeaderName = "TestSessionHeader"; diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Encoding/Encoders/TextEncodingTests.4.1.0.cs b/src/System.Private.ServiceModel/tests/Scenarios/Encoding/Encoders/TextEncodingTests.4.1.0.cs index 0a452a10af9..3a335c7aa0c 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Encoding/Encoders/TextEncodingTests.4.1.0.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Encoding/Encoders/TextEncodingTests.4.1.0.cs @@ -24,7 +24,7 @@ public static void TextMessageEncoder_WrongContentTypeResponse_Throws_ProtocolEx { // *** SETUP *** \\ binding = new BasicHttpBinding(BasicHttpSecurityMode.None); - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); serviceProxy = factory.CreateChannel(); // *** EXECUTE *** \\ @@ -57,7 +57,7 @@ public static void TextMessageEncoder_QuotedCharSet_In_Response_ContentType() { // *** SETUP *** \\ binding = new BasicHttpBinding(BasicHttpSecurityMode.None); - factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic)); + factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic_Text)); channel = factory.CreateChannel(); // *** EXECUTE *** \\ diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Extensibility/WebSockets/WebSocketTests.4.1.0.cs b/src/System.Private.ServiceModel/tests/Scenarios/Extensibility/WebSockets/WebSocketTests.4.1.0.cs index b8a258d5967..cbde47a349f 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Extensibility/WebSockets/WebSocketTests.4.1.0.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Extensibility/WebSockets/WebSocketTests.4.1.0.cs @@ -13,14 +13,20 @@ public class WebSocketTests : ConditionalWcfTest { - [WcfFact] - [Issue(1438, OS = OSID.Windows_7)] // not supported on Win7 + [WcfTheory] + [InlineData(NetHttpMessageEncoding.Binary)] + [InlineData(NetHttpMessageEncoding.Text)] + [InlineData(NetHttpMessageEncoding.Mtom)] [OuterLoop] - public static void WebSocket_Http_RequestReply_BinaryStreamed() + [Issue(1438, OS = OSID.Windows_7)] // not supported on Win7 + public static void WebSocket_Http_Duplex_Streamed(NetHttpMessageEncoding messageEncoding) { + string endpointAddress; NetHttpBinding binding = null; - ChannelFactory channelFactory = null; - IWSRequestReplyService client = null; + ClientReceiver clientReceiver = null; + InstanceContext context = null; + DuplexChannelFactory channelFactory = null; + IWSDuplexService client = null; FlowControlledStream uploadStream = null; try @@ -33,9 +39,13 @@ public static void WebSocket_Http_RequestReply_BinaryStreamed() }; binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; binding.TransferMode = TransferMode.Streamed; - binding.MessageEncoding = NetHttpMessageEncoding.Binary; + binding.MessageEncoding = messageEncoding; + + clientReceiver = new ClientReceiver(); + context = new InstanceContext(clientReceiver); - channelFactory = new ChannelFactory(binding, new EndpointAddress(Endpoints.WebSocketHttpRequestReplyBinaryStreamed_Address)); + endpointAddress = Endpoints.WebSocketHttpDuplexStreamed_Address + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding); + channelFactory = new DuplexChannelFactory(context, binding, endpointAddress); client = channelFactory.CreateChannel(); // *** EXECUTE *** \\ @@ -44,7 +54,6 @@ public static void WebSocket_Http_RequestReply_BinaryStreamed() int readResult; // Read from the stream, 1000 bytes at a time. byte[] buffer = new byte[1000]; - do { readResult = stream.Read(buffer, 0, buffer.Length); @@ -52,17 +61,42 @@ public static void WebSocket_Http_RequestReply_BinaryStreamed() while (readResult != 0); } + uploadStream = new FlowControlledStream(); + uploadStream.ReadThrottle = TimeSpan.FromMilliseconds(500); + uploadStream.StreamDuration = TimeSpan.FromSeconds(1); + + client.UploadStream(uploadStream); + client.StartPushingStream(); + // Wait for the callback to get invoked before telling the service to stop streaming. + // This ensures we can read from the stream on the callback while the NCL layer at the service + // is still writing the bytes from the stream to the wire. + // This will deadlock if the transfer mode is buffered because the callback will wait for the + // stream, and the NCL layer will continue to buffer the stream until it reaches the end. + + Assert.True(clientReceiver.ReceiveStreamInvoked.WaitOne(ScenarioTestHelpers.TestTimeout), + String.Format("Test case timeout was reached while waiting for the stream response from the Service. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); + clientReceiver.ReceiveStreamInvoked.Reset(); + + // Upload the stream while we are downloading a different stream uploadStream = new FlowControlledStream(); uploadStream.ReadThrottle = TimeSpan.FromMilliseconds(500); uploadStream.StreamDuration = TimeSpan.FromSeconds(1); client.UploadStream(uploadStream); + client.StopPushingStream(); + // Waiting on ReceiveStreamCompleted from the ClientReceiver. + Assert.True(clientReceiver.ReceiveStreamCompleted.WaitOne(ScenarioTestHelpers.TestTimeout), + String.Format("Test case timeout was reached while waiting for the stream response from the Service to be completed. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); + clientReceiver.ReceiveStreamCompleted.Reset(); + + // Getting results from server via callback. + client.GetLog(); + Assert.True(clientReceiver.LogReceived.WaitOne(ScenarioTestHelpers.TestTimeout), + String.Format("Test case timeout was reached while waiting for the Logging from the Service to be received. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); + // *** VALIDATE *** \\ - foreach (string serverLogItem in client.GetLog()) - { - //Assert.True(serverLogItem != ScenarioTestHelpers.RemoteEndpointMessagePropertyFailure, ScenarioTestHelpers.RemoteEndpointMessagePropertyFailure); - Assert.True(!ScenarioTestHelpers.IsLocalHost() || !serverLogItem.Contains(ScenarioTestHelpers.RemoteEndpointMessagePropertyFailure), serverLogItem); - } + Assert.True(clientReceiver.ServerLog.Count > 0, + "The logging done by the Server was not returned via the Callback."); // *** CLEANUP *** \\ ((ICommunicationObject)client).Close(); @@ -72,20 +106,24 @@ public static void WebSocket_Http_RequestReply_BinaryStreamed() { // *** ENSURE CLEANUP *** \\ ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)client, channelFactory); + clientReceiver.Dispose(); } } - [WcfFact] - [OuterLoop] + [WcfTheory] + [InlineData(NetHttpMessageEncoding.Binary)] + [InlineData(NetHttpMessageEncoding.Text)] + [InlineData(NetHttpMessageEncoding.Mtom)] [Issue(1438, OS = OSID.Windows_7)] // not supported on Win7 - public static void WebSocket_Http_Duplex_BinaryStreamed() + [OuterLoop] + public static void WebSocket_Http_Duplex_Buffered(NetHttpMessageEncoding messageEncoding) { + EndpointAddress endpointAddress; NetHttpBinding binding = null; ClientReceiver clientReceiver = null; InstanceContext context = null; DuplexChannelFactory channelFactory = null; IWSDuplexService client = null; - FlowControlledStream uploadStream = null; try { @@ -96,55 +134,28 @@ public static void WebSocket_Http_Duplex_BinaryStreamed() MaxBufferSize = ScenarioTestHelpers.SixtyFourMB, }; binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - binding.TransferMode = TransferMode.Streamed; - binding.MessageEncoding = NetHttpMessageEncoding.Binary; + binding.MessageEncoding = messageEncoding; clientReceiver = new ClientReceiver(); context = new InstanceContext(clientReceiver); - - channelFactory = new DuplexChannelFactory(context, binding, Endpoints.WebSocketHttpDuplexBinaryStreamed_Address); + endpointAddress = new EndpointAddress(Endpoints.WebSocketHttpDuplexBuffered_Address + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding)); + channelFactory = new DuplexChannelFactory(context, binding, endpointAddress); client = channelFactory.CreateChannel(); // *** EXECUTE *** \\ - using (Stream stream = client.DownloadStream()) - { - int readResult; - // Read from the stream, 1000 bytes at a time. - byte[] buffer = new byte[1000]; - do - { - readResult = stream.Read(buffer, 0, buffer.Length); - } - while (readResult != 0); - } - - uploadStream = new FlowControlledStream(); - uploadStream.ReadThrottle = TimeSpan.FromMilliseconds(500); - uploadStream.StreamDuration = TimeSpan.FromSeconds(1); - - client.UploadStream(uploadStream); - client.StartPushingStream(); - // Wait for the callback to get invoked before telling the service to stop streaming. - // This ensures we can read from the stream on the callback while the NCL layer at the service - // is still writing the bytes from the stream to the wire. - // This will deadlock if the transfer mode is buffered because the callback will wait for the - // stream, and the NCL layer will continue to buffer the stream until it reaches the end. - - Assert.True(clientReceiver.ReceiveStreamInvoked.WaitOne(ScenarioTestHelpers.TestTimeout), - String.Format("Test case timeout was reached while waiting for the stream response from the Service. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); - clientReceiver.ReceiveStreamInvoked.Reset(); - - // Upload the stream while we are downloading a different stream - uploadStream = new FlowControlledStream(); - uploadStream.ReadThrottle = TimeSpan.FromMilliseconds(500); - uploadStream.StreamDuration = TimeSpan.FromSeconds(1); - client.UploadStream(uploadStream); + // Invoking UploadData + client.UploadData(ScenarioTestHelpers.CreateInterestingString(123)); - client.StopPushingStream(); - // Waiting on ReceiveStreamCompleted from the ClientReceiver. - Assert.True(clientReceiver.ReceiveStreamCompleted.WaitOne(ScenarioTestHelpers.TestTimeout), - String.Format("Test case timeout was reached while waiting for the stream response from the Service to be completed. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); - clientReceiver.ReceiveStreamCompleted.Reset(); + // Invoking StartPushingData + client.StartPushingData(); + Assert.True(clientReceiver.ReceiveDataInvoked.WaitOne(ScenarioTestHelpers.TestTimeout), + String.Format("Test case timeout was reached while waiting for the buffered response from the Service. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); + clientReceiver.ReceiveDataInvoked.Reset(); + // Invoking StopPushingData + client.StopPushingData(); + Assert.True(clientReceiver.ReceiveDataCompleted.WaitOne(ScenarioTestHelpers.TestTimeout), + String.Format("Test case timeout was reached while waiting for the buffered response from the Service to be completed. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); + clientReceiver.ReceiveDataCompleted.Reset(); // Getting results from server via callback. client.GetLog(); @@ -163,85 +174,56 @@ public static void WebSocket_Http_Duplex_BinaryStreamed() { // *** ENSURE CLEANUP *** \\ ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)client, channelFactory); - clientReceiver.Dispose(); } } - [WcfFact] - [Condition(nameof(Root_Certificate_Installed))] - [Issue(3572, OS = OSID.OSX_10_14)] + [WcfTheory] + [InlineData(NetHttpMessageEncoding.Binary)] + [InlineData(NetHttpMessageEncoding.Text)] + [InlineData(NetHttpMessageEncoding.Mtom)] [Issue(1438, OS = OSID.Windows_7)] // not supported on Win7 [OuterLoop] - public static void WebSocket_Https_Duplex_BinaryStreamed() + public static void WebSocket_Http_Duplex_Buffered_KeepAlive(NetHttpMessageEncoding messageEncoding) { - BinaryMessageEncodingBindingElement binaryMessageEncodingBindingElement = null; - HttpsTransportBindingElement httpsTransportBindingElement = null; - CustomBinding binding = null; + EndpointAddress endpointAddress; + NetHttpBinding binding = null; ClientReceiver clientReceiver = null; InstanceContext context = null; DuplexChannelFactory channelFactory = null; IWSDuplexService client = null; - FlowControlledStream uploadStream = null; try { // *** SETUP *** \\ - binaryMessageEncodingBindingElement = new BinaryMessageEncodingBindingElement(); - httpsTransportBindingElement = new HttpsTransportBindingElement() + binding = new NetHttpBinding() { MaxReceivedMessageSize = ScenarioTestHelpers.SixtyFourMB, MaxBufferSize = ScenarioTestHelpers.SixtyFourMB, - TransferMode = TransferMode.Streamed }; - httpsTransportBindingElement.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - binding = new CustomBinding(binaryMessageEncodingBindingElement, httpsTransportBindingElement); + binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; + binding.MessageEncoding = messageEncoding; + binding.WebSocketSettings.KeepAliveInterval = TimeSpan.FromSeconds(2); clientReceiver = new ClientReceiver(); context = new InstanceContext(clientReceiver); - - channelFactory = new DuplexChannelFactory(context, binding, Endpoints.WebSocketHttpsDuplexBinaryStreamed_Address); + endpointAddress = new EndpointAddress(Endpoints.WebSocketHttpDuplexBuffered_Address + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding)); + channelFactory = new DuplexChannelFactory(context, binding, endpointAddress); client = channelFactory.CreateChannel(); // *** EXECUTE *** \\ - using (Stream stream = client.DownloadStream()) - { - int readResult; - // Read from the stream, 1000 bytes at a time. - byte[] buffer = new byte[1000]; - do - { - readResult = stream.Read(buffer, 0, buffer.Length); - } - while (readResult != 0); - } - - uploadStream = new FlowControlledStream(); - uploadStream.ReadThrottle = TimeSpan.FromMilliseconds(500); - uploadStream.StreamDuration = TimeSpan.FromSeconds(1); - - client.UploadStream(uploadStream); - client.StartPushingStream(); - // Wait for the callback to get invoked before telling the service to stop streaming. - // This ensures we can read from the stream on the callback while the NCL layer at the service - // is still writing the bytes from the stream to the wire. - // This will deadlock if the transfer mode is buffered because the callback will wait for the - // stream, and the NCL layer will continue to buffer the stream until it reaches the end. - - Assert.True(clientReceiver.ReceiveStreamInvoked.WaitOne(ScenarioTestHelpers.TestTimeout), - String.Format("Test case timeout was reached while waiting for the stream response from the Service. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); - clientReceiver.ReceiveStreamInvoked.Reset(); - - // Upload the stream while we are downloading a different stream - uploadStream = new FlowControlledStream(); - uploadStream.ReadThrottle = TimeSpan.FromMilliseconds(500); - uploadStream.StreamDuration = TimeSpan.FromSeconds(1); - client.UploadStream(uploadStream); + // Invoking UploadData + client.UploadData(ScenarioTestHelpers.CreateInterestingString(123)); - client.StopPushingStream(); - // Waiting on ReceiveStreamCompleted from the ClientReceiver. - Assert.True(clientReceiver.ReceiveStreamCompleted.WaitOne(ScenarioTestHelpers.TestTimeout), - String.Format("Test case timeout was reached while waiting for the stream response from the Service to be completed. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); - clientReceiver.ReceiveStreamCompleted.Reset(); + // Invoking StartPushingData + client.StartPushingData(); + Assert.True(clientReceiver.ReceiveDataInvoked.WaitOne(ScenarioTestHelpers.TestTimeout), + String.Format("Test case timeout was reached while waiting for the buffered response from the Service. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); + clientReceiver.ReceiveDataInvoked.Reset(); + // Invoking StopPushingData + client.StopPushingData(); + Assert.True(clientReceiver.ReceiveDataCompleted.WaitOne(ScenarioTestHelpers.TestTimeout), + String.Format("Test case timeout was reached while waiting for the buffered response from the Service to be completed. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); + clientReceiver.ReceiveDataCompleted.Reset(); // Getting results from server via callback. client.GetLog(); @@ -258,21 +240,22 @@ public static void WebSocket_Https_Duplex_BinaryStreamed() } finally { - // *** ENSURE CLEANUP *** \\ + // *** ENSURE CLEANUP *** \\ ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)client, channelFactory); - clientReceiver.Dispose(); } } - [WcfFact] + [WcfTheory] + [InlineData(NetHttpMessageEncoding.Binary)] + [InlineData(NetHttpMessageEncoding.Text)] + [InlineData(NetHttpMessageEncoding.Mtom)] [Issue(3572, OS = OSID.OSX_10_14)] [Issue(1438, OS = OSID.Windows_7)] // not supported on Win7 [OuterLoop] - public static void WebSocket_Https_Duplex_TextStreamed() + public static void WebSocket_Https_Duplex_Streamed(NetHttpMessageEncoding messageEncoding) { - TextMessageEncodingBindingElement textMessageEncodingBindingElement = null; - HttpsTransportBindingElement httpsTransportBindingElement = null; - CustomBinding binding = null; + string endpointAddress; + NetHttpsBinding binding = null; ClientReceiver clientReceiver = null; InstanceContext context = null; DuplexChannelFactory channelFactory = null; @@ -282,20 +265,19 @@ public static void WebSocket_Https_Duplex_TextStreamed() try { // *** SETUP *** \\ - textMessageEncodingBindingElement = new TextMessageEncodingBindingElement(); - httpsTransportBindingElement = new HttpsTransportBindingElement() + binding = new NetHttpsBinding() { MaxReceivedMessageSize = ScenarioTestHelpers.SixtyFourMB, MaxBufferSize = ScenarioTestHelpers.SixtyFourMB, - TransferMode = TransferMode.Streamed }; - httpsTransportBindingElement.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - binding = new CustomBinding(textMessageEncodingBindingElement, httpsTransportBindingElement); + binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; + binding.TransferMode = TransferMode.Streamed; + binding.MessageEncoding = messageEncoding; clientReceiver = new ClientReceiver(); context = new InstanceContext(clientReceiver); - - channelFactory = new DuplexChannelFactory(context, binding, Endpoints.WebSocketHttpsDuplexTextStreamed_Address); + endpointAddress = Endpoints.WebSocketHttpsDuplexStreamed_Address + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding); + channelFactory = new DuplexChannelFactory(context, binding, endpointAddress); client = channelFactory.CreateChannel(); // *** EXECUTE *** \\ @@ -319,7 +301,7 @@ public static void WebSocket_Https_Duplex_TextStreamed() client.StartPushingStream(); // Wait for the callback to get invoked before telling the service to stop streaming. // This ensures we can read from the stream on the callback while the NCL layer at the service - // is still writing the bytes from the stream to the wire. + // is still writing the bytes from the stream to the wire. // This will deadlock if the transfer mode is buffered because the callback will wait for the // stream, and the NCL layer will continue to buffer the stream until it reaches the end. @@ -360,76 +342,55 @@ public static void WebSocket_Https_Duplex_TextStreamed() } } - [WcfFact] + [WcfTheory] + [InlineData(NetHttpMessageEncoding.Binary)] + [InlineData(NetHttpMessageEncoding.Text)] + [InlineData(NetHttpMessageEncoding.Mtom)] + [Condition(nameof(Root_Certificate_Installed))] + [Issue(3572, OS = OSID.OSX_10_14)] [Issue(1438, OS = OSID.Windows_7)] // not supported on Win7 [OuterLoop] - public static void WebSocket_Http_Duplex_TextStreamed() + public static void WebSocket_Https_Duplex_Buffered(NetHttpMessageEncoding messageEncoding) { - NetHttpBinding binding = null; + EndpointAddress endpointAddress; + NetHttpsBinding binding = null; ClientReceiver clientReceiver = null; InstanceContext context = null; DuplexChannelFactory channelFactory = null; IWSDuplexService client = null; - FlowControlledStream uploadStream = null; try { // *** SETUP *** \\ - binding = new NetHttpBinding() + binding = new NetHttpsBinding() { MaxReceivedMessageSize = ScenarioTestHelpers.SixtyFourMB, MaxBufferSize = ScenarioTestHelpers.SixtyFourMB, }; binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - binding.TransferMode = TransferMode.Streamed; - binding.MessageEncoding = NetHttpMessageEncoding.Text; + binding.TransferMode = TransferMode.Buffered; + binding.MessageEncoding = messageEncoding; clientReceiver = new ClientReceiver(); context = new InstanceContext(clientReceiver); - - channelFactory = new DuplexChannelFactory(context, binding, Endpoints.WebSocketHttpDuplexTextStreamed_Address); + endpointAddress = new EndpointAddress(Endpoints.WebSocketHttpsDuplexBuffered_Address + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding)); + channelFactory = new DuplexChannelFactory(context, binding, endpointAddress); client = channelFactory.CreateChannel(); // *** EXECUTE *** \\ - using (Stream stream = client.DownloadStream()) - { - int readResult; - // Read from the stream, 1000 bytes at a time. - byte[] buffer = new byte[1000]; - do - { - readResult = stream.Read(buffer, 0, buffer.Length); - } - while (readResult != 0); - } - - uploadStream = new FlowControlledStream(); - uploadStream.ReadThrottle = TimeSpan.FromMilliseconds(500); - uploadStream.StreamDuration = TimeSpan.FromSeconds(1); - - client.UploadStream(uploadStream); - client.StartPushingStream(); - // Wait for the callback to get invoked before telling the service to stop streaming. - // This ensures we can read from the stream on the callback while the NCL layer at the service - // is still writing the bytes from the stream to the wire. - // This will deadlock if the transfer mode is buffered because the callback will wait for the - // stream, and the NCL layer will continue to buffer the stream until it reaches the end. - - Assert.True(clientReceiver.ReceiveStreamInvoked.WaitOne(ScenarioTestHelpers.TestTimeout), - String.Format("Test case timeout was reached while waiting for the stream response from the Service. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); - clientReceiver.ReceiveStreamInvoked.Reset(); - - // Upload the stream while we are downloading a different stream - uploadStream = new FlowControlledStream(); - uploadStream.ReadThrottle = TimeSpan.FromMilliseconds(500); - uploadStream.StreamDuration = TimeSpan.FromSeconds(1); - client.UploadStream(uploadStream); + // Invoking UploadData + client.UploadData(ScenarioTestHelpers.CreateInterestingString(123)); - client.StopPushingStream(); - // Waiting on ReceiveStreamCompleted from the ClientReceiver. - Assert.True(clientReceiver.ReceiveStreamCompleted.WaitOne(ScenarioTestHelpers.TestTimeout), - String.Format("Test case timeout was reached while waiting for the stream response from the Service to be completed. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); - clientReceiver.ReceiveStreamCompleted.Reset(); + // Invoking StartPushingData + client.StartPushingData(); + Assert.True(clientReceiver.ReceiveDataInvoked.WaitOne(ScenarioTestHelpers.TestTimeout), + String.Format("Test case timeout was reached while waiting for the buffered response from the Service. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); + clientReceiver.ReceiveDataInvoked.Reset(); + // Invoking StopPushingData + client.StopPushingData(); + Assert.True(clientReceiver.ReceiveDataCompleted.WaitOne(ScenarioTestHelpers.TestTimeout), + String.Format("Test case timeout was reached while waiting for the buffered response from the Service to be completed. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); + clientReceiver.ReceiveDataCompleted.Reset(); // Getting results from server via callback. client.GetLog(); @@ -448,15 +409,18 @@ public static void WebSocket_Http_Duplex_TextStreamed() { // *** ENSURE CLEANUP *** \\ ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)client, channelFactory); - clientReceiver.Dispose(); } } - [WcfFact] + [WcfTheory] + [InlineData(NetHttpMessageEncoding.Binary)] + [InlineData(NetHttpMessageEncoding.Text)] + [InlineData(NetHttpMessageEncoding.Mtom)] [Issue(1438, OS = OSID.Windows_7)] // not supported on Win7 [OuterLoop] - public static void WebSocket_Http_RequestReply_TextStreamed() + public static void WebSocket_Http_RequestReply_Streamed(NetHttpMessageEncoding messageEncoding) { + EndpointAddress endpointAddress; NetHttpBinding binding = null; ChannelFactory channelFactory = null; IWSRequestReplyService client = null; @@ -472,9 +436,9 @@ public static void WebSocket_Http_RequestReply_TextStreamed() }; binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; binding.TransferMode = TransferMode.Streamed; - binding.MessageEncoding = NetHttpMessageEncoding.Text; - - channelFactory = new ChannelFactory(binding, new EndpointAddress(Endpoints.WebSocketHttpRequestReplyTextStreamed_Address)); + binding.MessageEncoding = messageEncoding; + endpointAddress = new EndpointAddress(Endpoints.WebSocketHttpRequestReplyStreamed_Address + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding)); + channelFactory = new ChannelFactory(binding, endpointAddress); client = channelFactory.CreateChannel(); // *** EXECUTE *** \\ @@ -514,161 +478,38 @@ public static void WebSocket_Http_RequestReply_TextStreamed() } } - [WcfFact] + [WcfTheory] + [InlineData(NetHttpMessageEncoding.Binary)] + [InlineData(NetHttpMessageEncoding.Text)] + [InlineData(NetHttpMessageEncoding.Mtom)] [Issue(1438, OS = OSID.Windows_7)] // not supported on Win7 [OuterLoop] - public static void WebSocket_Http_WSTransportUsageDefault_DuplexCallback_GuidRoundtrip() + public static void WebSocket_Http_RequestReply_Buffered(NetHttpMessageEncoding messageEncoding) { - DuplexChannelFactory factory = null; - IWcfDuplexService duplexProxy = null; - Guid guid = Guid.NewGuid(); + EndpointAddress endpointAddress; + NetHttpBinding binding = null; + ChannelFactory channelFactory = null; + IWSRequestReplyService client = null; try { - // *** SETUP *** \\ - NetHttpBinding binding = new NetHttpBinding(); + // *** SETUP *** \\ + binding = new NetHttpBinding() + { + MaxReceivedMessageSize = ScenarioTestHelpers.SixtyFourMB, + MaxBufferSize = ScenarioTestHelpers.SixtyFourMB, + }; + binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; + binding.TransferMode = TransferMode.Buffered; + binding.MessageEncoding = messageEncoding; + endpointAddress = new EndpointAddress(Endpoints.WebSocketHttpRequestReplyBuffered_Address + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding)); + channelFactory = new ChannelFactory(binding, endpointAddress); - // NetHttpBinding default value of WebSocketTransportSettings.WebSocketTransportUsage is "WhenDuplex" - // Therefore using a Duplex Contract will trigger the use of the WCF implementation of WebSockets. - WcfDuplexServiceCallback callbackService = new WcfDuplexServiceCallback(); - InstanceContext context = new InstanceContext(callbackService); + client = channelFactory.CreateChannel(); - factory = new DuplexChannelFactory(context, binding, new EndpointAddress(Endpoints.NetHttpDuplexWebSocket_Address)); - duplexProxy = factory.CreateChannel(); - - // *** EXECUTE *** \\ - Task.Run(() => duplexProxy.Ping(guid)); - Guid returnedGuid = callbackService.CallbackGuid; - - // *** VALIDATE *** \\ - Assert.True(guid == returnedGuid, string.Format("The sent GUID does not match the returned GUID. Sent '{0}', Received: '{1}'", guid, returnedGuid)); - - // *** CLEANUP *** \\ - ((ICommunicationObject)duplexProxy).Close(); - factory.Close(); - } - finally - { - // *** ENSURE CLEANUP *** \\ - ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)duplexProxy, factory); - } - } - - [WcfFact] - [Issue(1438, OS = OSID.Windows_7)] // not supported on Win7 - [OuterLoop] - public static void WebSocket_Http_WSTransportUsageAlways_DuplexCallback_GuidRoundtrip() - { - DuplexChannelFactory factory = null; - IWcfDuplexService duplexProxy = null; - Guid guid = Guid.NewGuid(); - - try - { - // *** SETUP *** \\ - NetHttpBinding binding = new NetHttpBinding(); - // Verifying the scenario works when explicitly setting the transport to use WebSockets. - binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - - WcfDuplexServiceCallback callbackService = new WcfDuplexServiceCallback(); - InstanceContext context = new InstanceContext(callbackService); - - factory = new DuplexChannelFactory(context, binding, new EndpointAddress(Endpoints.NetHttpWebSocketTransport_Address)); - duplexProxy = factory.CreateChannel(); - - // *** EXECUTE *** \\ - Task.Run(() => duplexProxy.Ping(guid)); - Guid returnedGuid = callbackService.CallbackGuid; - - // *** VALIDATE *** \\ - Assert.True(guid == returnedGuid, string.Format("The sent GUID does not match the returned GUID. Sent '{0}', Received: '{1}'", guid, returnedGuid)); - - // *** CLEANUP *** \\ - factory.Close(); - ((ICommunicationObject)duplexProxy).Close(); - } - finally - { - // *** ENSURE CLEANUP *** \\ - ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)duplexProxy, factory); - } - } - - [WcfFact] - [Issue(1438, OS = OSID.Windows_7)] // not supported on Win7 - [OuterLoop] - public static void WebSocket_WSScheme_WSTransportUsageAlways_DuplexCallback_GuidRoundtrip() - { - DuplexChannelFactory factory = null; - IWcfDuplexService proxy = null; - Guid guid = Guid.NewGuid(); - - try - { - // *** SETUP *** \\ - NetHttpBinding binding = new NetHttpBinding(); - binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - - WcfDuplexServiceCallback callbackService = new WcfDuplexServiceCallback(); - InstanceContext context = new InstanceContext(callbackService); - - UriBuilder builder = new UriBuilder(Endpoints.NetHttpWebSocketTransport_Address); - // Replacing "http" with "ws" as the uri scheme. - builder.Scheme = "ws"; - - factory = new DuplexChannelFactory(context, binding, new EndpointAddress(Endpoints.NetHttpWebSocketTransport_Address)); - proxy = factory.CreateChannel(); - - // *** EXECUTE *** \\ - Task.Run(() => proxy.Ping(guid)); - Guid returnedGuid = callbackService.CallbackGuid; - - // *** VALIDATE *** \\ - Assert.True(guid == returnedGuid, - string.Format("The sent GUID does not match the returned GUID. Sent '{0}', Received: '{1}'", guid, returnedGuid)); - - // *** CLEANUP *** \\ - factory.Close(); - ((ICommunicationObject)proxy).Close(); - } - finally - { - // *** ENSURE CLEANUP *** \\ - ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)proxy, factory); - } - } - - [WcfFact] - [Condition(nameof(Root_Certificate_Installed))] - [Issue(3572, OS = OSID.OSX_10_14)] - [Issue(1438, OS = OSID.Windows_7)] // not supported on Win7 - [OuterLoop] - public static void WebSocket_Https_RequestReply_BinaryBuffered() - { - BinaryMessageEncodingBindingElement binaryMessageEncodingBindingElement = null; - HttpsTransportBindingElement httpsTransportBindingElement = null; - CustomBinding binding = null; - ChannelFactory channelFactory = null; - IWSRequestReplyService client = null; - - try - { - // *** SETUP *** \\ - binaryMessageEncodingBindingElement = new BinaryMessageEncodingBindingElement(); - httpsTransportBindingElement = new HttpsTransportBindingElement() - { - MaxReceivedMessageSize = ScenarioTestHelpers.SixtyFourMB, - MaxBufferSize = ScenarioTestHelpers.SixtyFourMB, - }; - httpsTransportBindingElement.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - binding = new CustomBinding(binaryMessageEncodingBindingElement, httpsTransportBindingElement); - - channelFactory = new ChannelFactory(binding, new EndpointAddress(Endpoints.WebSocketHttpsRequestReplyBinaryBuffered_Address)); - client = channelFactory.CreateChannel(); - - // *** EXECUTE *** \\ - // Invoking DownloadData - string result = client.DownloadData(); + // *** EXECUTE *** \\ + // Invoking DownloadData + string result = client.DownloadData(); // Invoking UploadData client.UploadData(ScenarioTestHelpers.CreateInterestingString(123)); @@ -686,38 +527,37 @@ public static void WebSocket_Https_RequestReply_BinaryBuffered() } finally { - // *** ENSURE CLEANUP *** \\ + // *** ENSURE CLEANUP *** \\ ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)client, channelFactory); } } - [WcfFact] - [Condition(nameof(Root_Certificate_Installed))] - [Issue(3572, OS = OSID.OSX_10_14)] + [WcfTheory] + [InlineData(NetHttpMessageEncoding.Binary)] + [InlineData(NetHttpMessageEncoding.Text)] + [InlineData(NetHttpMessageEncoding.Mtom)] [Issue(1438, OS = OSID.Windows_7)] // not supported on Win7 [OuterLoop] - public static void WebSocket_Https_RequestReply_TextBuffered_KeepAlive() + public static void WebSocket_Http_RequestReply_Buffered_KeepAlive(NetHttpMessageEncoding messageEncoding) { - TextMessageEncodingBindingElement textMessageEncodingBindingElement = null; - HttpsTransportBindingElement httpsTransportBindingElement = null; - CustomBinding binding = null; + EndpointAddress endpointAddress; + NetHttpBinding binding = null; ChannelFactory channelFactory = null; IWSRequestReplyService client = null; try { // *** SETUP *** \\ - textMessageEncodingBindingElement = new TextMessageEncodingBindingElement(); - httpsTransportBindingElement = new HttpsTransportBindingElement() + binding = new NetHttpBinding() { MaxReceivedMessageSize = ScenarioTestHelpers.SixtyFourMB, - MaxBufferSize = ScenarioTestHelpers.SixtyFourMB + MaxBufferSize = ScenarioTestHelpers.SixtyFourMB, }; - httpsTransportBindingElement.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - httpsTransportBindingElement.WebSocketSettings.KeepAliveInterval = TimeSpan.FromSeconds(2); - binding = new CustomBinding(textMessageEncodingBindingElement, httpsTransportBindingElement); - - channelFactory = new ChannelFactory(binding, new EndpointAddress(Endpoints.WebSocketHttpsRequestReplyTextBuffered_Address)); + binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; + binding.MessageEncoding = messageEncoding; + binding.WebSocketSettings.KeepAliveInterval = TimeSpan.FromSeconds(2); + endpointAddress = new EndpointAddress(Endpoints.WebSocketHttpRequestReplyBuffered_Address + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding)); + channelFactory = new ChannelFactory(binding, endpointAddress); client = channelFactory.CreateChannel(); @@ -746,62 +586,49 @@ public static void WebSocket_Https_RequestReply_TextBuffered_KeepAlive() } } - [WcfFact] + [WcfTheory] + [InlineData(NetHttpMessageEncoding.Binary)] + [InlineData(NetHttpMessageEncoding.Text)] + [InlineData(NetHttpMessageEncoding.Mtom)] [Condition(nameof(Root_Certificate_Installed))] [Issue(3572, OS = OSID.OSX_10_14)] [Issue(1438, OS = OSID.Windows_7)] // not supported on Win7 [OuterLoop] - public static void WebSocket_Https_Duplex_BinaryBuffered() + public static void WebSocket_Https_RequestReply_Buffered(NetHttpMessageEncoding messageEncoding) { - BinaryMessageEncodingBindingElement binaryMessageEncodingBindingElement = null; - HttpsTransportBindingElement httpsTransportBindingElement = null; - CustomBinding binding = null; - ClientReceiver clientReceiver = null; - InstanceContext context = null; - DuplexChannelFactory channelFactory = null; - IWSDuplexService client = null; + EndpointAddress endpointAddress; + NetHttpsBinding binding = null; + ChannelFactory channelFactory = null; + IWSRequestReplyService client = null; try { // *** SETUP *** \\ - binaryMessageEncodingBindingElement = new BinaryMessageEncodingBindingElement(); - httpsTransportBindingElement = new HttpsTransportBindingElement() + binding = new NetHttpsBinding() { MaxReceivedMessageSize = ScenarioTestHelpers.SixtyFourMB, MaxBufferSize = ScenarioTestHelpers.SixtyFourMB, }; - httpsTransportBindingElement.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - binding = new CustomBinding(binaryMessageEncodingBindingElement, httpsTransportBindingElement); - - clientReceiver = new ClientReceiver(); - context = new InstanceContext(clientReceiver); - - channelFactory = new DuplexChannelFactory(context, binding, new EndpointAddress(Endpoints.WebSocketHttpsDuplexBinaryBuffered_Address)); + binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; + binding.TransferMode = TransferMode.Buffered; + binding.MessageEncoding = messageEncoding; + endpointAddress = new EndpointAddress(Endpoints.WebSocketHttpsRequestReplyBuffered_Address + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding)); + channelFactory = new ChannelFactory(binding, endpointAddress); client = channelFactory.CreateChannel(); // *** EXECUTE *** \\ + // Invoking DownloadData + string result = client.DownloadData(); + // Invoking UploadData client.UploadData(ScenarioTestHelpers.CreateInterestingString(123)); - // Invoking StartPushingData - client.StartPushingData(); - Assert.True(clientReceiver.ReceiveDataInvoked.WaitOne(ScenarioTestHelpers.TestTimeout), - String.Format("Test case timeout was reached while waiting for the buffered response from the Service. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); - clientReceiver.ReceiveDataInvoked.Reset(); - // Invoking StopPushingData - client.StopPushingData(); - Assert.True(clientReceiver.ReceiveDataCompleted.WaitOne(ScenarioTestHelpers.TestTimeout), - String.Format("Test case timeout was reached while waiting for the buffered response from the Service to be completed. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); - clientReceiver.ReceiveDataCompleted.Reset(); - - // Getting results from server via callback. - client.GetLog(); - Assert.True(clientReceiver.LogReceived.WaitOne(ScenarioTestHelpers.TestTimeout), - String.Format("Test case timeout was reached while waiting for the Logging from the Service to be received. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); - // *** VALIDATE *** \\ - Assert.True(clientReceiver.ServerLog.Count > 0, - "The logging done by the Server was not returned via the Callback."); + foreach (string serverLogItem in client.GetLog()) + { + //Assert.True(serverLogItem != ScenarioTestHelpers.RemoteEndpointMessagePropertyFailure, ScenarioTestHelpers.RemoteEndpointMessagePropertyFailure); + Assert.True(!ScenarioTestHelpers.IsLocalHost() || !serverLogItem.Contains(ScenarioTestHelpers.RemoteEndpointMessagePropertyFailure), serverLogItem); + } // *** CLEANUP *** \\ ((ICommunicationObject)client).Close(); @@ -809,100 +636,40 @@ public static void WebSocket_Https_Duplex_BinaryBuffered() } finally { - // *** ENSURE CLEANUP *** \\ + // *** ENSURE CLEANUP *** \\ ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)client, channelFactory); } } - [WcfFact] + [WcfTheory] + [InlineData(NetHttpMessageEncoding.Binary)] + [InlineData(NetHttpMessageEncoding.Text)] + [InlineData(NetHttpMessageEncoding.Mtom)] [Condition(nameof(Root_Certificate_Installed))] [Issue(3572, OS = OSID.OSX_10_14)] [Issue(1438, OS = OSID.Windows_7)] // not supported on Win7 [OuterLoop] - public static void WebSocket_Https_Duplex_TextBuffered_KeepAlive() - { - TextMessageEncodingBindingElement textMessageEncodingBindingElement = null; - HttpsTransportBindingElement httpsTransportBindingElement = null; - CustomBinding binding = null; - ClientReceiver clientReceiver = null; - InstanceContext context = null; - DuplexChannelFactory channelFactory = null; - IWSDuplexService client = null; - - try - { - // *** SETUP *** \\ - textMessageEncodingBindingElement = new TextMessageEncodingBindingElement(); - httpsTransportBindingElement = new HttpsTransportBindingElement() - { - MaxReceivedMessageSize = ScenarioTestHelpers.SixtyFourMB, - MaxBufferSize = ScenarioTestHelpers.SixtyFourMB - }; - httpsTransportBindingElement.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - httpsTransportBindingElement.WebSocketSettings.KeepAliveInterval = TimeSpan.FromSeconds(2); - binding = new CustomBinding(textMessageEncodingBindingElement, httpsTransportBindingElement); - - clientReceiver = new ClientReceiver(); - context = new InstanceContext(clientReceiver); - channelFactory = new DuplexChannelFactory(context, binding, new EndpointAddress(Endpoints.WebSocketHttpsDuplexTextBuffered_Address)); - client = channelFactory.CreateChannel(); - - // *** EXECUTE *** \\ - // Invoking UploadData - client.UploadData(ScenarioTestHelpers.CreateInterestingString(123)); - - // Invoking StartPushingData - client.StartPushingData(); - Assert.True(clientReceiver.ReceiveDataInvoked.WaitOne(ScenarioTestHelpers.TestTimeout), - String.Format("Test case timeout was reached while waiting for the buffered response from the Service. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); - clientReceiver.ReceiveDataInvoked.Reset(); - // Invoking StopPushingData - client.StopPushingData(); - Assert.True(clientReceiver.ReceiveDataCompleted.WaitOne(ScenarioTestHelpers.TestTimeout), - String.Format("Test case timeout was reached while waiting for the buffered response from the Service to be completed. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); - clientReceiver.ReceiveDataCompleted.Reset(); - - // Getting results from server via callback. - client.GetLog(); - Assert.True(clientReceiver.LogReceived.WaitOne(ScenarioTestHelpers.TestTimeout), - String.Format("Test case timeout was reached while waiting for the Logging from the Service to be received. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); - - // *** VALIDATE *** \\ - Assert.True(clientReceiver.ServerLog.Count > 0, - "The logging done by the Server was not returned via the Callback."); - - // *** CLEANUP *** \\ - ((ICommunicationObject)client).Close(); - channelFactory.Close(); - } - finally - { - // *** ENSURE CLEANUP *** \\ - ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)client, channelFactory); - } - } - - [WcfFact] - [Issue(1438, OS = OSID.Windows_7)] // not supported on Win7 - [OuterLoop] - public static void WebSocket_Http_RequestReply_TextBuffered() + public static void WebSocket_Https_RequestReply_Buffered_KeepAlive(NetHttpMessageEncoding messageEncoding) { - NetHttpBinding binding = null; + EndpointAddress endpointAddress; + NetHttpsBinding binding = null; ChannelFactory channelFactory = null; IWSRequestReplyService client = null; try { // *** SETUP *** \\ - binding = new NetHttpBinding() + binding = new NetHttpsBinding() { MaxReceivedMessageSize = ScenarioTestHelpers.SixtyFourMB, MaxBufferSize = ScenarioTestHelpers.SixtyFourMB, }; binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - binding.MessageEncoding = NetHttpMessageEncoding.Text; - - channelFactory = new ChannelFactory(binding, new EndpointAddress(Endpoints.WebSocketHttpRequestReplyTextBuffered_Address)); + binding.WebSocketSettings.KeepAliveInterval = TimeSpan.FromSeconds(2); + binding.TransferMode = TransferMode.Buffered; + binding.MessageEncoding = messageEncoding; + endpointAddress = new EndpointAddress(Endpoints.WebSocketHttpsRequestReplyBuffered_Address + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding)); + channelFactory = new ChannelFactory(binding, endpointAddress); client = channelFactory.CreateChannel(); @@ -926,7 +693,7 @@ public static void WebSocket_Http_RequestReply_TextBuffered() } finally { - // *** ENSURE CLEANUP *** \\ + // *** ENSURE CLEANUP *** \\ ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)client, channelFactory); } } @@ -934,175 +701,124 @@ public static void WebSocket_Http_RequestReply_TextBuffered() [WcfFact] [Issue(1438, OS = OSID.Windows_7)] // not supported on Win7 [OuterLoop] - public static void WebSocket_Http_RequestReply_BinaryBuffered_KeepAlive() + public static void WebSocket_Http_WSTransportUsageDefault_DuplexCallback_GuidRoundtrip() { - NetHttpBinding binding = null; - ChannelFactory channelFactory = null; - IWSRequestReplyService client = null; + DuplexChannelFactory factory = null; + IWcfDuplexService duplexProxy = null; + Guid guid = Guid.NewGuid(); try { - // *** SETUP *** \\ - binding = new NetHttpBinding() - { - MaxReceivedMessageSize = ScenarioTestHelpers.SixtyFourMB, - MaxBufferSize = ScenarioTestHelpers.SixtyFourMB, - }; - binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - binding.MessageEncoding = NetHttpMessageEncoding.Binary; - binding.WebSocketSettings.KeepAliveInterval = TimeSpan.FromSeconds(2); - - channelFactory = new ChannelFactory(binding, new EndpointAddress(Endpoints.WebSocketHttpRequestReplyBinaryBuffered_Address)); + // *** SETUP *** \\ + NetHttpBinding binding = new NetHttpBinding(); - client = channelFactory.CreateChannel(); + // NetHttpBinding default value of WebSocketTransportSettings.WebSocketTransportUsage is "WhenDuplex" + // Therefore using a Duplex Contract will trigger the use of the WCF implementation of WebSockets. + WcfDuplexServiceCallback callbackService = new WcfDuplexServiceCallback(); + InstanceContext context = new InstanceContext(callbackService); - // *** EXECUTE *** \\ - // Invoking DownloadData - string result = client.DownloadData(); + factory = new DuplexChannelFactory(context, binding, new EndpointAddress(Endpoints.NetHttpDuplexWebSocket_Address)); + duplexProxy = factory.CreateChannel(); - // Invoking UploadData - client.UploadData(ScenarioTestHelpers.CreateInterestingString(123)); + // *** EXECUTE *** \\ + Task.Run(() => duplexProxy.Ping(guid)); + Guid returnedGuid = callbackService.CallbackGuid; - // *** VALIDATE *** \\ - foreach (string serverLogItem in client.GetLog()) - { - //Assert.True(serverLogItem != ScenarioTestHelpers.RemoteEndpointMessagePropertyFailure, ScenarioTestHelpers.RemoteEndpointMessagePropertyFailure); - Assert.True(!ScenarioTestHelpers.IsLocalHost() || !serverLogItem.Contains(ScenarioTestHelpers.RemoteEndpointMessagePropertyFailure), serverLogItem); - } + // *** VALIDATE *** \\ + Assert.True(guid == returnedGuid, string.Format("The sent GUID does not match the returned GUID. Sent '{0}', Received: '{1}'", guid, returnedGuid)); - // *** CLEANUP *** \\ - ((ICommunicationObject)client).Close(); - channelFactory.Close(); + // *** CLEANUP *** \\ + ((ICommunicationObject)duplexProxy).Close(); + factory.Close(); } finally { // *** ENSURE CLEANUP *** \\ - ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)client, channelFactory); + ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)duplexProxy, factory); } } [WcfFact] [Issue(1438, OS = OSID.Windows_7)] // not supported on Win7 [OuterLoop] - public static void WebSocket_Http_Duplex_TextBuffered_KeepAlive() + public static void WebSocket_Http_WSTransportUsageAlways_DuplexCallback_GuidRoundtrip() { - NetHttpBinding binding = null; - ClientReceiver clientReceiver = null; - InstanceContext context = null; - DuplexChannelFactory channelFactory = null; - IWSDuplexService client = null; + DuplexChannelFactory factory = null; + IWcfDuplexService duplexProxy = null; + Guid guid = Guid.NewGuid(); try { - // *** SETUP *** \\ - binding = new NetHttpBinding() - { - MaxReceivedMessageSize = ScenarioTestHelpers.SixtyFourMB, - MaxBufferSize = ScenarioTestHelpers.SixtyFourMB, - }; + // *** SETUP *** \\ + NetHttpBinding binding = new NetHttpBinding(); + // Verifying the scenario works when explicitly setting the transport to use WebSockets. binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - binding.MessageEncoding = NetHttpMessageEncoding.Text; - binding.WebSocketSettings.KeepAliveInterval = TimeSpan.FromSeconds(2); - clientReceiver = new ClientReceiver(); - context = new InstanceContext(clientReceiver); - channelFactory = new DuplexChannelFactory(context, binding, new EndpointAddress(Endpoints.WebSocketHttpDuplexTextBuffered_Address)); - client = channelFactory.CreateChannel(); - - // *** EXECUTE *** \\ - // Invoking UploadData - client.UploadData(ScenarioTestHelpers.CreateInterestingString(123)); + WcfDuplexServiceCallback callbackService = new WcfDuplexServiceCallback(); + InstanceContext context = new InstanceContext(callbackService); - // Invoking StartPushingData - client.StartPushingData(); - Assert.True(clientReceiver.ReceiveDataInvoked.WaitOne(ScenarioTestHelpers.TestTimeout), - String.Format("Test case timeout was reached while waiting for the buffered response from the Service. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); - clientReceiver.ReceiveDataInvoked.Reset(); - // Invoking StopPushingData - client.StopPushingData(); - Assert.True(clientReceiver.ReceiveDataCompleted.WaitOne(ScenarioTestHelpers.TestTimeout), - String.Format("Test case timeout was reached while waiting for the buffered response from the Service to be completed. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); - clientReceiver.ReceiveDataCompleted.Reset(); + factory = new DuplexChannelFactory(context, binding, new EndpointAddress(Endpoints.NetHttpWebSocketTransport_Address)); + duplexProxy = factory.CreateChannel(); - // Getting results from server via callback. - client.GetLog(); - Assert.True(clientReceiver.LogReceived.WaitOne(ScenarioTestHelpers.TestTimeout), - String.Format("Test case timeout was reached while waiting for the Logging from the Service to be received. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); + // *** EXECUTE *** \\ + Task.Run(() => duplexProxy.Ping(guid)); + Guid returnedGuid = callbackService.CallbackGuid; - // *** VALIDATE *** \\ - Assert.True(clientReceiver.ServerLog.Count > 0, - "The logging done by the Server was not returned via the Callback."); + // *** VALIDATE *** \\ + Assert.True(guid == returnedGuid, string.Format("The sent GUID does not match the returned GUID. Sent '{0}', Received: '{1}'", guid, returnedGuid)); - // *** CLEANUP *** \\ - ((ICommunicationObject)client).Close(); - channelFactory.Close(); + // *** CLEANUP *** \\ + factory.Close(); + ((ICommunicationObject)duplexProxy).Close(); } finally { // *** ENSURE CLEANUP *** \\ - ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)client, channelFactory); + ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)duplexProxy, factory); } } [WcfFact] [Issue(1438, OS = OSID.Windows_7)] // not supported on Win7 [OuterLoop] - public static void WebSocket_Http_Duplex_BinaryBuffered() + public static void WebSocket_WSScheme_WSTransportUsageAlways_DuplexCallback_GuidRoundtrip() { - NetHttpBinding binding = null; - ClientReceiver clientReceiver = null; - InstanceContext context = null; - DuplexChannelFactory channelFactory = null; - IWSDuplexService client = null; + DuplexChannelFactory factory = null; + IWcfDuplexService proxy = null; + Guid guid = Guid.NewGuid(); try { - // *** SETUP *** \\ - binding = new NetHttpBinding() - { - MaxReceivedMessageSize = ScenarioTestHelpers.SixtyFourMB, - MaxBufferSize = ScenarioTestHelpers.SixtyFourMB, - }; + // *** SETUP *** \\ + NetHttpBinding binding = new NetHttpBinding(); binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - binding.MessageEncoding = NetHttpMessageEncoding.Binary; - clientReceiver = new ClientReceiver(); - context = new InstanceContext(clientReceiver); - channelFactory = new DuplexChannelFactory(context, binding, new EndpointAddress(Endpoints.WebSocketHttpDuplexBinaryBuffered_Address)); - client = channelFactory.CreateChannel(); + WcfDuplexServiceCallback callbackService = new WcfDuplexServiceCallback(); + InstanceContext context = new InstanceContext(callbackService); - // *** EXECUTE *** \\ - // Invoking UploadData - client.UploadData(ScenarioTestHelpers.CreateInterestingString(123)); + UriBuilder builder = new UriBuilder(Endpoints.NetHttpWebSocketTransport_Address); + // Replacing "http" with "ws" as the uri scheme. + builder.Scheme = "ws"; - // Invoking StartPushingData - client.StartPushingData(); - Assert.True(clientReceiver.ReceiveDataInvoked.WaitOne(ScenarioTestHelpers.TestTimeout), - String.Format("Test case timeout was reached while waiting for the buffered response from the Service. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); - clientReceiver.ReceiveDataInvoked.Reset(); - // Invoking StopPushingData - client.StopPushingData(); - Assert.True(clientReceiver.ReceiveDataCompleted.WaitOne(ScenarioTestHelpers.TestTimeout), - String.Format("Test case timeout was reached while waiting for the buffered response from the Service to be completed. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); - clientReceiver.ReceiveDataCompleted.Reset(); + factory = new DuplexChannelFactory(context, binding, new EndpointAddress(Endpoints.NetHttpWebSocketTransport_Address)); + proxy = factory.CreateChannel(); - // Getting results from server via callback. - client.GetLog(); - Assert.True(clientReceiver.LogReceived.WaitOne(ScenarioTestHelpers.TestTimeout), - String.Format("Test case timeout was reached while waiting for the Logging from the Service to be received. Timeout was: {0}", ScenarioTestHelpers.TestTimeout)); + // *** EXECUTE *** \\ + Task.Run(() => proxy.Ping(guid)); + Guid returnedGuid = callbackService.CallbackGuid; - // *** VALIDATE *** \\ - Assert.True(clientReceiver.ServerLog.Count > 0, - "The logging done by the Server was not returned via the Callback."); + // *** VALIDATE *** \\ + Assert.True(guid == returnedGuid, + string.Format("The sent GUID does not match the returned GUID. Sent '{0}', Received: '{1}'", guid, returnedGuid)); - // *** CLEANUP *** \\ - ((ICommunicationObject)client).Close(); - channelFactory.Close(); + // *** CLEANUP *** \\ + factory.Close(); + ((ICommunicationObject)proxy).Close(); } finally { // *** ENSURE CLEANUP *** \\ - ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)client, channelFactory); + ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)proxy, factory); } } diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Security/TransportSecurity/Https/HttpsTests.4.1.0.cs b/src/System.Private.ServiceModel/tests/Scenarios/Security/TransportSecurity/Https/HttpsTests.4.1.0.cs index b1a3e033cd6..34023645573 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Security/TransportSecurity/Https/HttpsTests.4.1.0.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Security/TransportSecurity/Https/HttpsTests.4.1.0.cs @@ -16,6 +16,54 @@ public partial class HttpsTests : ConditionalWcfTest { + [WcfTheory] + [InlineData(WSMessageEncoding.Text)] + [InlineData(WSMessageEncoding.Mtom)] + [Issue(2870, OS = OSID.AnyOSX)] + [Condition(nameof(Root_Certificate_Installed), + nameof(Client_Certificate_Installed), + nameof(Server_Accepts_Certificates), + nameof(SSL_Available))] + [OuterLoop] + public static void DefaultSettings_Echo_RoundTrips_String(WSMessageEncoding messageEncoding) + { + ChannelFactory factory = null; + IWcfService serviceProxy = null; + string testString = "Hello"; + + try + { + // *** SETUP *** \\ + BasicHttpsBinding basicHttpsBinding = new BasicHttpsBinding(BasicHttpsSecurityMode.Transport); + basicHttpsBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate; + basicHttpsBinding.MessageEncoding = messageEncoding; + + string clientCertThumb = ServiceUtilHelper.ClientCertificate.Thumbprint; + factory = new ChannelFactory(basicHttpsBinding, new EndpointAddress(Endpoints.Https_DefaultBinding_Address + Enum.GetName(typeof(WSMessageEncoding), messageEncoding))); + factory.Credentials.ClientCertificate.SetCertificate( + StoreLocation.CurrentUser, + StoreName.My, + X509FindType.FindByThumbprint, + clientCertThumb); + serviceProxy = factory.CreateChannel(); + + // *** EXECUTE *** \\ + string result = serviceProxy.Echo(testString); + + // *** VALIDATE *** \\ + Assert.True(result == testString, String.Format("Error: expected response from service: '{0}' Actual was: '{1}'", testString, result)); + + // *** CLEANUP *** \\ + factory.Close(); + ((ICommunicationObject)serviceProxy).Close(); + } + finally + { + // *** ENSURE CLEANUP *** \\ + ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy, factory); + } + } + // Client: CustomBinding set MessageVersion to Soap11 // Server: BasicHttpsBinding default value is Soap11 [WcfFact] @@ -33,7 +81,7 @@ public static void CrossBinding_Soap11_EchoString() try { CustomBinding binding = new CustomBinding(new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8), new HttpsTransportBindingElement()); - ChannelFactory factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.Https_DefaultBinding_Address)); + ChannelFactory factory = new ChannelFactory(binding, new EndpointAddress(Endpoints.Https_DefaultBinding_Address_Text)); IWcfService serviceProxy = factory.CreateChannel(); string result = serviceProxy.Echo(testString); @@ -192,7 +240,7 @@ public static void ServerCertificateValidation_EchoString() // *** SETUP *** \\ CustomBinding binding = new CustomBinding(new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8), new HttpsTransportBindingElement()); - endpointAddress = new EndpointAddress(new Uri(Endpoints.Https_DefaultBinding_Address)); + endpointAddress = new EndpointAddress(new Uri(Endpoints.Https_DefaultBinding_Address_Text)); clientCertThumb = ServiceUtilHelper.ClientCertificate.Thumbprint; factory = new ChannelFactory(binding, endpointAddress); @@ -240,7 +288,7 @@ public static async Task ServerCertificateValidationUsingIdentity_EchoString() serviceCertificate = await ServiceUtilHelper.GetServiceMacineCertFromServerAsync(); var identity = new X509CertificateEndpointIdentity(serviceCertificate); - endpointAddress = new EndpointAddress(new Uri(Endpoints.Https_DefaultBinding_Address), identity); + endpointAddress = new EndpointAddress(new Uri(Endpoints.Https_DefaultBinding_Address_Text), identity); factory = new ChannelFactory(binding, endpointAddress); serviceProxy = factory.CreateChannel(); @@ -281,7 +329,7 @@ public static void ServerCertificateValidationUsingIdentity_Throws_EchoString() // This is intentionally the wrong certificate var identity = new X509CertificateEndpointIdentity(ServiceUtilHelper.ClientCertificate); - endpointAddress = new EndpointAddress(new Uri(Endpoints.Https_DefaultBinding_Address), identity); + endpointAddress = new EndpointAddress(new Uri(Endpoints.Https_DefaultBinding_Address_Text), identity); factory = new ChannelFactory(binding, endpointAddress); serviceProxy = factory.CreateChannel(); diff --git a/src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/BasicHttpTestServiceHost.cs b/src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/BasicHttpTestServiceHost.cs index ad6ca522eba..4e5384e60d1 100644 --- a/src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/BasicHttpTestServiceHost.cs +++ b/src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/BasicHttpTestServiceHost.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.ServiceModel; using System.ServiceModel.Channels; @@ -11,11 +12,17 @@ namespace WcfService [TestServiceDefinition(BasePath = "BasicHttp.svc", Schema = ServiceSchema.HTTP)] public class BasicHttpTestServiceHost : TestServiceHostBase { - protected override string Address { get { return "Basic"; } } + protected override IList GetBindings() + { + return new List { GetBasicHttpBinding(WSMessageEncoding.Text), GetBasicHttpBinding(WSMessageEncoding.Mtom) }; + } - protected override Binding GetBinding() + private Binding GetBasicHttpBinding(WSMessageEncoding messageEncoding) { - return new BasicHttpBinding(); + var binding = new BasicHttpBinding(); + binding.MessageEncoding = messageEncoding; + binding.Name = Enum.GetName(typeof(WSMessageEncoding), messageEncoding); + return binding; } public BasicHttpTestServiceHost(params Uri[] baseAddresses) diff --git a/src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/BasicHttpsTestServiceHost.cs b/src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/BasicHttpsTestServiceHost.cs index 6529a5d87d3..5e83c6bb0d6 100644 --- a/src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/BasicHttpsTestServiceHost.cs +++ b/src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/BasicHttpsTestServiceHost.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.ServiceModel; using System.ServiceModel.Channels; @@ -11,11 +12,17 @@ namespace WcfService [TestServiceDefinition(Schema = ServiceSchema.HTTPS, BasePath = "BasicHttps.svc")] public class BasicHttpsTestServiceHost : TestServiceHostBase { - protected override string Address { get { return "basicHttps"; } } + protected override IList GetBindings() + { + return new List { GetBasicHttpsBinding(WSMessageEncoding.Text), GetBasicHttpsBinding(WSMessageEncoding.Mtom) }; + } - protected override Binding GetBinding() + private Binding GetBasicHttpsBinding(WSMessageEncoding messageEncoding) { - return new BasicHttpsBinding(); + var binding = new BasicHttpsBinding(); + binding.MessageEncoding = messageEncoding; + binding.Name = Enum.GetName(typeof(WSMessageEncoding), messageEncoding); + return binding; } public BasicHttpsTestServiceHost(params Uri[] baseAddresses) diff --git a/src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/NetHttpTestServiceHost.cs b/src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/NetHttpTestServiceHost.cs index 9c64983b169..2569c367bcb 100644 --- a/src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/NetHttpTestServiceHost.cs +++ b/src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/NetHttpTestServiceHost.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.ServiceModel; using System.ServiceModel.Channels; @@ -11,11 +12,21 @@ namespace WcfService [TestServiceDefinition(Schema = ServiceSchema.HTTP, BasePath = "NetHttp.svc")] public class NetHttpTestServiceHost : TestServiceHostBase { - protected override string Address { get { return "NetHttp"; } } + protected override IList GetBindings() + { + return new List { + GetNetHttpBinding(NetHttpMessageEncoding.Binary), + GetNetHttpBinding(NetHttpMessageEncoding.Text), + GetNetHttpBinding(NetHttpMessageEncoding.Mtom) + }; + } - protected override Binding GetBinding() + private Binding GetNetHttpBinding(NetHttpMessageEncoding encoding) { - return new NetHttpBinding(); + var binding = new NetHttpBinding(); + binding.MessageEncoding = encoding; + binding.Name = Enum.GetName(typeof(NetHttpMessageEncoding), encoding); + return binding; } public NetHttpTestServiceHost(params Uri[] baseAddresses) diff --git a/src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/NetHttpsTestServiceHost.cs b/src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/NetHttpsTestServiceHost.cs index 8e8869960f7..e72615a819c 100644 --- a/src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/NetHttpsTestServiceHost.cs +++ b/src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/NetHttpsTestServiceHost.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.ServiceModel; using System.ServiceModel.Channels; @@ -11,11 +12,21 @@ namespace WcfService [TestServiceDefinition(Schema = ServiceSchema.HTTPS, BasePath = "NetHttps.svc")] public class NetHttpsTestServiceHost : TestServiceHostBase { - protected override string Address { get { return "NetHttps"; } } + protected override IList GetBindings() + { + return new List { + GetNetHttpBinding(NetHttpMessageEncoding.Binary), + GetNetHttpBinding(NetHttpMessageEncoding.Text), + GetNetHttpBinding(NetHttpMessageEncoding.Mtom) + }; + } - protected override Binding GetBinding() + private Binding GetNetHttpBinding(NetHttpMessageEncoding encoding) { - return new NetHttpsBinding(); + var binding = new NetHttpsBinding(); + binding.MessageEncoding = encoding; + binding.Name = Enum.GetName(typeof(NetHttpMessageEncoding), encoding); + return binding; } public NetHttpsTestServiceHost(params Uri[] baseAddresses) diff --git a/src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/WSHttpBindingTestServiceHost.cs b/src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/WSHttpBindingTestServiceHost.cs new file mode 100644 index 00000000000..f4ef56e8149 --- /dev/null +++ b/src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/WSHttpBindingTestServiceHost.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.ServiceModel; +using System.ServiceModel.Channels; + +namespace WcfService +{ + [TestServiceDefinition(BasePath = "WSHttp.svc", Schema = ServiceSchema.HTTP)] + public class WSHttpBindingTestServiceHost : TestServiceHostBase + { + protected override IList GetBindings() + { + return new List { GetWSHttpBinding(WSMessageEncoding.Text), GetWSHttpBinding(WSMessageEncoding.Mtom) }; + } + + private Binding GetWSHttpBinding(WSMessageEncoding messageEncoding) + { + var binding = new WSHttpBinding(SecurityMode.None); + binding.MessageEncoding = messageEncoding; + binding.Name = Enum.GetName(typeof(WSMessageEncoding), messageEncoding); + return binding; + } + + public WSHttpBindingTestServiceHost(params Uri[] baseAddresses) + : base(typeof(WcfService), baseAddresses) + { + } + } +} diff --git a/src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/WebSocketTestServiceHosts.cs b/src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/WebSocketTestServiceHosts.cs index 4ef4d0e4d80..968c4bf7ae0 100644 --- a/src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/WebSocketTestServiceHosts.cs +++ b/src/System.Private.ServiceModel/tools/IISHostedWcfService/App_code/testhosts/WebSocketTestServiceHosts.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.ServiceModel; using System.ServiceModel.Channels; @@ -42,110 +43,29 @@ public WebSocketTransportTestServiceHost(params Uri[] baseAddresses) } } - [TestServiceDefinition(Schema = ServiceSchema.WS, BasePath = "WebSocketHttpDuplexBinaryStreamed.svc")] - public class WebSocketHttpDuplexBinaryStreamedTestServiceHost : TestServiceHostBase + [TestServiceDefinition(Schema = ServiceSchema.WSS, BasePath = "WebSocketHttpsDuplex.svc")] + [TestServiceDefinition(Schema = ServiceSchema.WS, BasePath = "WebSocketHttpDuplex.svc")] + public class WebSocketHttpDuplexTestServiceHost : TestServiceHostBase { - protected override string Address { get { return "WebSocketHttpDuplexBinaryStreamedResource"; } } - - protected override Binding GetBinding() - { - NetHttpBinding binding = new NetHttpBinding() - { - MaxReceivedMessageSize = SixtyFourMB, - MaxBufferSize = SixtyFourMB, - }; - binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - binding.TransferMode = TransferMode.Streamed; - binding.MessageEncoding = NetHttpMessageEncoding.Binary; - return binding; - } - - public WebSocketHttpDuplexBinaryStreamedTestServiceHost(params Uri[] baseAddresses) - : base(typeof(WSDuplexService), baseAddresses) - { - } - } - - [TestServiceDefinition(Schema = ServiceSchema.WS, BasePath = "WebSocketHttpRequestReplyBinaryStreamed.svc")] - public class WebSocketHttpRequestReplyBinaryStreamedTestServiceHost : TestServiceHostBase - { - protected override string Address { get { return "WebSocketHttpRequestReplyBinaryStreamedResource"; } } - - protected override Binding GetBinding() - { - NetHttpBinding binding = new NetHttpBinding() - { - MaxReceivedMessageSize = SixtyFourMB, - MaxBufferSize = SixtyFourMB, - }; - binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - binding.TransferMode = TransferMode.Streamed; - binding.MessageEncoding = NetHttpMessageEncoding.Binary; - return binding; - } - - public WebSocketHttpRequestReplyBinaryStreamedTestServiceHost(params Uri[] baseAddresses) - : base(typeof(WSRequestReplyService), baseAddresses) - { - } - } - - [TestServiceDefinition(Schema = ServiceSchema.WSS, BasePath = "WebSocketHttpsDuplexBinaryStreamed.svc")] - public class WebSocketHttpsDuplexBinaryStreamedTestServiceHost : TestServiceHostBase - { - protected override string Address { get { return "WebSocketHttpsDuplexBinaryStreamedResource"; } } - - protected override Binding GetBinding() - { - BinaryMessageEncodingBindingElement binaryMessageEncodingBindingElement = new BinaryMessageEncodingBindingElement(); - HttpsTransportBindingElement httpsTransportBindingElement = new HttpsTransportBindingElement() - { - MaxReceivedMessageSize = SixtyFourMB, - MaxBufferSize = SixtyFourMB, - TransferMode = TransferMode.Streamed - }; - httpsTransportBindingElement.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - CustomBinding binding = new CustomBinding(binaryMessageEncodingBindingElement, httpsTransportBindingElement); - return binding; - } - - public WebSocketHttpsDuplexBinaryStreamedTestServiceHost(params Uri[] baseAddresses) - : base(typeof(WSDuplexService), baseAddresses) - { - } - } - - [TestServiceDefinition(Schema = ServiceSchema.WSS, BasePath = "WebSocketHttpsDuplexTextStreamed.svc")] - public class WebSocketHttpsDuplexTextStreamedTestServiceHost : TestServiceHostBase - { - protected override string Address { get { return "WebSocketHttpsDuplexTextStreamedResource"; } } - - protected override Binding GetBinding() + protected override IList GetBindings() { - TextMessageEncodingBindingElement textMessageEncodingBindingElement = new TextMessageEncodingBindingElement(); - HttpsTransportBindingElement httpsTransportBindingElement = new HttpsTransportBindingElement() - { - MaxReceivedMessageSize = SixtyFourMB, - MaxBufferSize = SixtyFourMB, - TransferMode = TransferMode.Streamed + return new List { + GetNetHttpBinding(NetHttpMessageEncoding.Text, TransferMode.Buffered), + GetNetHttpBinding(NetHttpMessageEncoding.Binary, TransferMode.Buffered), + GetNetHttpBinding(NetHttpMessageEncoding.Mtom, TransferMode.Buffered), + GetNetHttpBinding(NetHttpMessageEncoding.Text, TransferMode.Streamed), + GetNetHttpBinding(NetHttpMessageEncoding.Binary, TransferMode.Streamed), + GetNetHttpBinding(NetHttpMessageEncoding.Mtom, TransferMode.Streamed), + GetNetHttpsBinding(NetHttpMessageEncoding.Text, TransferMode.Buffered), + GetNetHttpsBinding(NetHttpMessageEncoding.Binary, TransferMode.Buffered), + GetNetHttpsBinding(NetHttpMessageEncoding.Mtom, TransferMode.Buffered), + GetNetHttpsBinding(NetHttpMessageEncoding.Text, TransferMode.Streamed), + GetNetHttpsBinding(NetHttpMessageEncoding.Binary, TransferMode.Streamed), + GetNetHttpsBinding(NetHttpMessageEncoding.Mtom, TransferMode.Streamed) }; - httpsTransportBindingElement.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - CustomBinding binding = new CustomBinding(textMessageEncodingBindingElement, httpsTransportBindingElement); - return binding; } - public WebSocketHttpsDuplexTextStreamedTestServiceHost(params Uri[] baseAddresses) - : base(typeof(WSDuplexService), baseAddresses) - { - } - } - - [TestServiceDefinition(Schema = ServiceSchema.WS, BasePath = "WebSocketHttpRequestReplyTextStreamed.svc")] - public class WebSocketHttpRequestReplyTextStreamedTestServiceHost : TestServiceHostBase - { - protected override string Address { get { return "WebSocketHttpRequestReplyTextStreamedResource"; } } - - protected override Binding GetBinding() + private Binding GetNetHttpBinding(NetHttpMessageEncoding messageEncoding, TransferMode transferMode) { NetHttpBinding binding = new NetHttpBinding() { @@ -153,94 +73,57 @@ protected override Binding GetBinding() MaxBufferSize = SixtyFourMB, }; binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - binding.TransferMode = TransferMode.Streamed; - binding.MessageEncoding = NetHttpMessageEncoding.Text; + binding.TransferMode = transferMode; + binding.MessageEncoding = messageEncoding; + binding.Name = Enum.GetName(typeof(TransferMode), transferMode) + + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding); return binding; } - public WebSocketHttpRequestReplyTextStreamedTestServiceHost(params Uri[] baseAddresses) - : base(typeof(WSRequestReplyService), baseAddresses) + private Binding GetNetHttpsBinding(NetHttpMessageEncoding messageEncoding, TransferMode transferMode) { - } - } - - [TestServiceDefinition(Schema = ServiceSchema.WS, BasePath = "WebSocketHttpDuplexTextStreamed.svc")] - public class WebSocketHttpDuplexTextStreamedTestServiceHost : TestServiceHostBase - { - protected override string Address { get { return "WebSocketHttpDuplexTextStreamedResource"; } } - - protected override Binding GetBinding() - { - NetHttpBinding binding = new NetHttpBinding() + NetHttpsBinding binding = new NetHttpsBinding() { MaxReceivedMessageSize = SixtyFourMB, MaxBufferSize = SixtyFourMB, }; binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - binding.TransferMode = TransferMode.Streamed; - binding.MessageEncoding = NetHttpMessageEncoding.Text; + binding.TransferMode = transferMode; + binding.MessageEncoding = messageEncoding; + binding.Name = Enum.GetName(typeof(TransferMode), transferMode) + + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding); return binding; } - public WebSocketHttpDuplexTextStreamedTestServiceHost(params Uri[] baseAddresses) + public WebSocketHttpDuplexTestServiceHost(params Uri[] baseAddresses) : base(typeof(WSDuplexService), baseAddresses) { } } - [TestServiceDefinition(Schema = ServiceSchema.WS, BasePath = "WebSocketHttpRequestReplyTextBuffered.svc")] - public class WebSocketHttpRequestReplyTextBufferedTestServiceHost : TestServiceHostBase - { - protected override string Address { get { return "WebSocketHttpRequestReplyTextBufferedResource"; } } - - protected override Binding GetBinding() - { - NetHttpBinding binding = new NetHttpBinding() - { - MaxReceivedMessageSize = SixtyFourMB, - MaxBufferSize = SixtyFourMB, - }; - binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - binding.MessageEncoding = NetHttpMessageEncoding.Text; - return binding; - } - - public WebSocketHttpRequestReplyTextBufferedTestServiceHost(params Uri[] baseAddresses) - : base(typeof(WSRequestReplyService), baseAddresses) - { - } - } - - [TestServiceDefinition(Schema = ServiceSchema.WS, BasePath = "WebSocketHttpRequestReplyBinaryBuffered.svc")] - public class WebSocketHttpRequestReplyBinaryBufferedTestServiceHost : TestServiceHostBase + [TestServiceDefinition(Schema = ServiceSchema.WSS, BasePath = "WebSocketHttpsRequestReply.svc")] + [TestServiceDefinition(Schema = ServiceSchema.WS, BasePath = "WebSocketHttpRequestReply.svc")] + public class WebSocketHttpRequestReplyTestServiceHost : TestServiceHostBase { - protected override string Address { get { return "WebSocketHttpRequestReplyBinaryBufferedResource"; } } - - protected override Binding GetBinding() + protected override IList GetBindings() { - NetHttpBinding binding = new NetHttpBinding() - { - MaxReceivedMessageSize = SixtyFourMB, - MaxBufferSize = SixtyFourMB, + return new List { + GetNetHttpBinding(NetHttpMessageEncoding.Text, TransferMode.Buffered), + GetNetHttpBinding(NetHttpMessageEncoding.Binary, TransferMode.Buffered), + GetNetHttpBinding(NetHttpMessageEncoding.Mtom, TransferMode.Buffered), + GetNetHttpBinding(NetHttpMessageEncoding.Text, TransferMode.Streamed), + GetNetHttpBinding(NetHttpMessageEncoding.Binary, TransferMode.Streamed), + GetNetHttpBinding(NetHttpMessageEncoding.Mtom, TransferMode.Streamed), + GetNetHttpsBinding(NetHttpMessageEncoding.Text, TransferMode.Buffered), + GetNetHttpsBinding(NetHttpMessageEncoding.Binary, TransferMode.Buffered), + GetNetHttpsBinding(NetHttpMessageEncoding.Mtom, TransferMode.Buffered), + GetNetHttpsBinding(NetHttpMessageEncoding.Text, TransferMode.Streamed), + GetNetHttpsBinding(NetHttpMessageEncoding.Binary, TransferMode.Streamed), + GetNetHttpsBinding(NetHttpMessageEncoding.Mtom, TransferMode.Streamed) }; - binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - binding.MessageEncoding = NetHttpMessageEncoding.Binary; - return binding; } - public WebSocketHttpRequestReplyBinaryBufferedTestServiceHost(params Uri[] baseAddresses) - : base(typeof(WSRequestReplyService), baseAddresses) - { - } - } - - - [TestServiceDefinition(Schema = ServiceSchema.WS, BasePath = "WebSocketHttpDuplexTextBuffered.svc")] - public class WebSocketHttpDuplexTextBufferedTestServiceHost : TestServiceHostBase - { - protected override string Address { get { return "WebSocketHttpDuplexTextBufferedResource"; } } - - protected override Binding GetBinding() + private Binding GetNetHttpBinding(NetHttpMessageEncoding messageEncoding, TransferMode transferMode) { NetHttpBinding binding = new NetHttpBinding() { @@ -248,135 +131,34 @@ protected override Binding GetBinding() MaxBufferSize = SixtyFourMB, }; binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - binding.MessageEncoding = NetHttpMessageEncoding.Text; + binding.TransferMode = transferMode; + binding.MessageEncoding = messageEncoding; + binding.Name = Enum.GetName(typeof(TransferMode), transferMode) + + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding); return binding; } - public WebSocketHttpDuplexTextBufferedTestServiceHost(params Uri[] baseAddresses) - : base(typeof(WSDuplexService), baseAddresses) + private Binding GetNetHttpsBinding(NetHttpMessageEncoding messageEncoding, TransferMode transferMode) { - } - } - - - [TestServiceDefinition(Schema = ServiceSchema.WS, BasePath = "WebSocketHttpDuplexBinaryBuffered.svc")] - public class WebSocketHttpDuplexBinaryBufferedTestServiceHost : TestServiceHostBase - { - protected override string Address { get { return "WebSocketHttpDuplexBinaryBufferedResource"; } } - - protected override Binding GetBinding() - { - NetHttpBinding binding = new NetHttpBinding() + NetHttpsBinding binding = new NetHttpsBinding() { MaxReceivedMessageSize = SixtyFourMB, MaxBufferSize = SixtyFourMB, }; binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - binding.MessageEncoding = NetHttpMessageEncoding.Binary; - return binding; - } - - public WebSocketHttpDuplexBinaryBufferedTestServiceHost(params Uri[] baseAddresses) - : base(typeof(WSDuplexService), baseAddresses) - { - } - } - - [TestServiceDefinition(Schema = ServiceSchema.WSS, BasePath = "WebSocketHttpsRequestReplyBinaryBuffered.svc")] - public class WebSocketHttpsRequestReplyBinaryBufferedTestServiceHost : TestServiceHostBase - { - protected override string Address { get { return "WebSocketHttpsRequestReplyBinaryBufferedResource"; } } - - protected override Binding GetBinding() - { - BinaryMessageEncodingBindingElement binaryMessageEncodingBindingElement = new BinaryMessageEncodingBindingElement(); - HttpsTransportBindingElement httpsTransportBindingElement = new HttpsTransportBindingElement() - { - MaxReceivedMessageSize = SixtyFourMB, - MaxBufferSize = SixtyFourMB, - }; - httpsTransportBindingElement.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - CustomBinding binding = new CustomBinding(binaryMessageEncodingBindingElement, httpsTransportBindingElement); + binding.TransferMode = transferMode; + binding.MessageEncoding = messageEncoding; + binding.Name = Enum.GetName(typeof(TransferMode), transferMode) + + Enum.GetName(typeof(NetHttpMessageEncoding), messageEncoding); return binding; } - public WebSocketHttpsRequestReplyBinaryBufferedTestServiceHost(params Uri[] baseAddresses) - : base(typeof(WSRequestReplyService), baseAddresses) - { - } - } - - [TestServiceDefinition(Schema = ServiceSchema.WSS, BasePath = "WebSocketHttpsRequestReplyTextBuffered.svc")] - public class WebSocketHttpsRequestReplyTextBufferedTestServiceHost : TestServiceHostBase - { - protected override string Address { get { return "WebSocketHttpsRequestReplyTextBufferedResource"; } } - protected override Binding GetBinding() - { - TextMessageEncodingBindingElement textMessageEncodingBindingElement = new TextMessageEncodingBindingElement(); - HttpsTransportBindingElement httpsTransportBindingElement = new HttpsTransportBindingElement() - { - MaxReceivedMessageSize = SixtyFourMB, - MaxBufferSize = SixtyFourMB - }; - httpsTransportBindingElement.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - CustomBinding binding = new CustomBinding(textMessageEncodingBindingElement, httpsTransportBindingElement); - return binding; - } - - public WebSocketHttpsRequestReplyTextBufferedTestServiceHost(params Uri[] baseAddresses) + public WebSocketHttpRequestReplyTestServiceHost(params Uri[] baseAddresses) : base(typeof(WSRequestReplyService), baseAddresses) { } } - [TestServiceDefinition(Schema = ServiceSchema.WSS, BasePath = "WebSocketHttpsDuplexBinaryBuffered.svc")] - public class WebSocketHttpsDuplexBinaryBufferedTestServiceHost : TestServiceHostBase - { - protected override string Address { get { return "WebSocketHttpsDuplexBinaryBufferedResource"; } } - - protected override Binding GetBinding() - { - BinaryMessageEncodingBindingElement binaryMessageEncodingBindingElement = new BinaryMessageEncodingBindingElement(); - HttpsTransportBindingElement httpsTransportBindingElement = new HttpsTransportBindingElement() - { - MaxReceivedMessageSize = SixtyFourMB, - MaxBufferSize = SixtyFourMB, - }; - httpsTransportBindingElement.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - CustomBinding binding = new CustomBinding(binaryMessageEncodingBindingElement, httpsTransportBindingElement); - return binding; - } - public WebSocketHttpsDuplexBinaryBufferedTestServiceHost(params Uri[] baseAddresses) - : base(typeof(WSDuplexService), baseAddresses) - { - } - } - - [TestServiceDefinition(Schema = ServiceSchema.WSS, BasePath = "WebSocketHttpsDuplexTextBuffered.svc")] - public class WebSocketHttpsDuplexTextBufferedTestServiceHost : TestServiceHostBase - { - protected override string Address { get { return "WebSocketHttpsDuplexTextBufferedResource"; } } - - protected override Binding GetBinding() - { - TextMessageEncodingBindingElement textMessageEncodingBindingElement = new TextMessageEncodingBindingElement(); - HttpsTransportBindingElement httpsTransportBindingElement = new HttpsTransportBindingElement() - { - MaxReceivedMessageSize = SixtyFourMB, - MaxBufferSize = SixtyFourMB - }; - httpsTransportBindingElement.WebSocketSettings.TransportUsage = WebSocketTransportUsage.Always; - CustomBinding binding = new CustomBinding(textMessageEncodingBindingElement, httpsTransportBindingElement); - return binding; - } - - public WebSocketHttpsDuplexTextBufferedTestServiceHost(params Uri[] baseAddresses) - : base(typeof(WSDuplexService), baseAddresses) - { - } - } - - [TestServiceDefinition(Schema = ServiceSchema.WS, BasePath = "WebSocketHttpVerifyWebSocketsUsed.svc")] public class WebSocketHttpVerifyWebSocketsUsedTestServiceHost : TestServiceHostBase { diff --git a/src/System.ServiceModel.Http/ref/System.ServiceModel.Http.cs b/src/System.ServiceModel.Http/ref/System.ServiceModel.Http.cs index f2f8a517c15..f442c1d189d 100644 --- a/src/System.ServiceModel.Http/ref/System.ServiceModel.Http.cs +++ b/src/System.ServiceModel.Http/ref/System.ServiceModel.Http.cs @@ -11,6 +11,7 @@ public partial class BasicHttpBinding : System.ServiceModel.HttpBindingBase { public BasicHttpBinding() { } public BasicHttpBinding(System.ServiceModel.BasicHttpSecurityMode securityMode) { } + public System.ServiceModel.WSMessageEncoding MessageEncoding { get { return default; } set { } } public System.ServiceModel.BasicHttpSecurity Security { get { return default; } set { } } public override System.ServiceModel.Channels.IChannelFactory BuildChannelFactory(System.ServiceModel.Channels.BindingParameterCollection parameters) { return default; } public override System.ServiceModel.Channels.BindingElementCollection CreateBindingElements() { return default; } @@ -46,6 +47,7 @@ public partial class BasicHttpsBinding : System.ServiceModel.HttpBindingBase public BasicHttpsBinding() { } public BasicHttpsBinding(System.ServiceModel.BasicHttpsSecurityMode securityMode) { } public System.ServiceModel.BasicHttpsSecurity Security { get { return default; } set { } } + public System.ServiceModel.WSMessageEncoding MessageEncoding { get { return default; } set { } } public override System.ServiceModel.Channels.IChannelFactory BuildChannelFactory(System.ServiceModel.Channels.BindingParameterCollection parameters) { return default; } public override System.ServiceModel.Channels.BindingElementCollection CreateBindingElements() { return default; } } @@ -153,7 +155,7 @@ protected WSHttpBindingBase(bool reliableSessionEnabled) { } //public System.ServiceModel.HostNameComparisonMode HostNameComparisonMode { get { return default; } set { } } public long MaxBufferPoolSize { get { return default; } set { } } public long MaxReceivedMessageSize { get { return default; } set { } } - //public System.ServiceModel.WSMessageEncoding MessageEncoding { get { return default; } set { } } + public System.ServiceModel.WSMessageEncoding MessageEncoding { get { return default; } set { } } public Uri ProxyAddress { get { return default; } set { } } public System.Xml.XmlDictionaryReaderQuotas ReaderQuotas { get { return default; } set { } } public System.ServiceModel.OptionalReliableSession ReliableSession { get { return default; } set { } } @@ -205,11 +207,11 @@ public MessageSecurityOverHttp() { } public System.ServiceModel.Security.SecurityAlgorithmSuite AlgorithmSuite { get { return default; } set { } } protected virtual bool IsSecureConversationEnabled() { return default; } } - //public enum WSMessageEncoding - //{ - // Text = 0, - // Mtom, - //} + public enum WSMessageEncoding + { + Text = 0, + Mtom, + } } namespace System.ServiceModel.Channels { From 80292702c7746002a9328c766f99c03eb8afbeb6 Mon Sep 17 00:00:00 2001 From: Matt Connew Date: Tue, 10 Aug 2021 16:05:52 -0700 Subject: [PATCH 2/2] PR feedback --- .../System/Xml/XmlExceptionHelper.cs | 21 --------------- .../src/Internals/System/Xml/XmlMtomWriter.cs | 27 ++++++++++--------- 2 files changed, 14 insertions(+), 34 deletions(-) diff --git a/src/System.Private.ServiceModel/src/Internals/System/Xml/XmlExceptionHelper.cs b/src/System.Private.ServiceModel/src/Internals/System/Xml/XmlExceptionHelper.cs index 8b229abfff5..95357406a0d 100644 --- a/src/System.Private.ServiceModel/src/Internals/System/Xml/XmlExceptionHelper.cs +++ b/src/System.Private.ServiceModel/src/Internals/System/Xml/XmlExceptionHelper.cs @@ -9,11 +9,6 @@ namespace System.Xml { internal static class XmlExceptionHelper { - static void ThrowXmlException(XmlDictionaryReader reader, string res) - { - ThrowXmlException(reader, res, null); - } - static void ThrowXmlException(XmlDictionaryReader reader, string res, string arg1) { ThrowXmlException(reader, res, arg1, null); @@ -33,22 +28,6 @@ static void ThrowXmlException(XmlDictionaryReader reader, string res, string arg s += " " + SR.Format(SR.XmlLineInfo, lineInfo.LineNumber, lineInfo.LinePosition); } - //if (TD.ReaderQuotaExceededIsEnabled()) - //{ - // TD.ReaderQuotaExceeded(s); - //} - - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(s)); - } - - static public void ThrowXmlException(XmlDictionaryReader reader, XmlException exception) - { - string s = exception.Message; - IXmlLineInfo lineInfo = reader as IXmlLineInfo; - if (lineInfo != null && lineInfo.HasLineInfo()) - { - s += " " + SR.Format(SR.XmlLineInfo, lineInfo.LineNumber, lineInfo.LinePosition); - } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(s)); } diff --git a/src/System.Private.ServiceModel/src/Internals/System/Xml/XmlMtomWriter.cs b/src/System.Private.ServiceModel/src/Internals/System/Xml/XmlMtomWriter.cs index 136d4ead913..9a2d5bc4197 100644 --- a/src/System.Private.ServiceModel/src/Internals/System/Xml/XmlMtomWriter.cs +++ b/src/System.Private.ServiceModel/src/Internals/System/Xml/XmlMtomWriter.cs @@ -139,7 +139,7 @@ private void Initialize() WriteMimeHeaders(_contentID, _initialContentTypeForRootPart, _isUTF8 ? MimeGlobals.Encoding8bit : MimeGlobals.EncodingBinary); - Stream infosetContentStream = _mimeWriter.GetContentStreamAsync().GetAwaiter().GetResult(); + Stream infosetContentStream = _mimeWriter.GetContentStream(); IXmlTextWriterInitializer initializer = _writer as IXmlTextWriterInitializer; if (initializer == null) _writer = XmlDictionaryWriter.CreateTextWriter(infosetContentStream, _encoding, _ownsStream); @@ -1215,7 +1215,7 @@ internal void StartPreface() state = MimeWriterState.StartPreface; } - internal async Task StartPartAsync() + internal void StartPart() { switch (state) { @@ -1230,7 +1230,7 @@ internal async Task StartPartAsync() if (contentStream != null) { - await contentStream.FlushAsync(); + contentStream.Flush(); contentStream = null; } @@ -1238,7 +1238,8 @@ internal async Task StartPartAsync() bufferedWrite.Write(MimeGlobals.CRLF); } - internal void StartPart() + + internal async Task StartPartAsync() { switch (state) { @@ -1253,7 +1254,7 @@ internal void StartPart() if (contentStream != null) { - contentStream.Flush(); + await contentStream.FlushAsync(); contentStream = null; } @@ -1311,20 +1312,20 @@ internal async Task CloseAsync() await FlushAsync(); } - private async Task FlushAsync() + private void Flush() { if (bufferedWrite.Length > 0) { - await stream.WriteAsync(bufferedWrite.GetBuffer(), 0, bufferedWrite.Length); + stream.Write(bufferedWrite.GetBuffer(), 0, bufferedWrite.Length); bufferedWrite.Reset(); } } - private void Flush() + private async Task FlushAsync() { if (bufferedWrite.Length > 0) { - stream.Write(bufferedWrite.GetBuffer(), 0, bufferedWrite.Length); + await stream.WriteAsync(bufferedWrite.GetBuffer(), 0, bufferedWrite.Length); bufferedWrite.Reset(); } } @@ -1354,7 +1355,7 @@ internal void WriteHeader(string name, string value) bufferedWrite.Write(MimeGlobals.CRLF); } - internal async Task GetContentStreamAsync() + internal Stream GetContentStream() { switch (state) { @@ -1368,12 +1369,12 @@ internal async Task GetContentStreamAsync() state = MimeWriterState.Content; bufferedWrite.Write(MimeGlobals.CRLF); - await FlushAsync(); + Flush(); contentStream = stream; return contentStream; } - internal Stream GetContentStream() + internal async Task GetContentStreamAsync() { switch (state) { @@ -1387,7 +1388,7 @@ internal Stream GetContentStream() state = MimeWriterState.Content; bufferedWrite.Write(MimeGlobals.CRLF); - Flush(); + await FlushAsync(); contentStream = stream; return contentStream; }