WebMessageFormatter.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. //
  2. // WebMessageFormatter.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. // Copyright (C) 2008,2009 Novell, Inc (http://www.novell.com)
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. using System;
  29. using System.Collections.Generic;
  30. using System.Globalization;
  31. using System.IO;
  32. using System.Reflection;
  33. using System.Runtime.Serialization;
  34. using System.Runtime.Serialization.Json;
  35. using System.ServiceModel;
  36. using System.ServiceModel.Channels;
  37. using System.ServiceModel.Description;
  38. using System.ServiceModel.Web;
  39. using System.Text;
  40. using System.Xml;
  41. #if NET_2_1
  42. using XmlObjectSerializer = System.Object;
  43. #endif
  44. namespace System.ServiceModel.Dispatcher
  45. {
  46. internal abstract class WebMessageFormatter
  47. {
  48. OperationDescription operation;
  49. ServiceEndpoint endpoint;
  50. QueryStringConverter converter;
  51. WebHttpBehavior behavior;
  52. UriTemplate template;
  53. WebAttributeInfo info = null;
  54. public WebMessageFormatter (OperationDescription operation, ServiceEndpoint endpoint, QueryStringConverter converter, WebHttpBehavior behavior)
  55. {
  56. this.operation = operation;
  57. this.endpoint = endpoint;
  58. this.converter = converter;
  59. this.behavior = behavior;
  60. ApplyWebAttribute ();
  61. #if !NET_2_1
  62. // This is a hack for WebScriptEnablingBehavior
  63. var jqc = converter as JsonQueryStringConverter;
  64. if (jqc != null)
  65. BodyName = jqc.CustomWrapperName;
  66. #endif
  67. }
  68. void ApplyWebAttribute ()
  69. {
  70. MethodInfo mi = operation.SyncMethod ?? operation.BeginMethod;
  71. object [] atts = mi.GetCustomAttributes (typeof (WebGetAttribute), false);
  72. if (atts.Length > 0)
  73. info = ((WebGetAttribute) atts [0]).Info;
  74. atts = mi.GetCustomAttributes (typeof (WebInvokeAttribute), false);
  75. if (atts.Length > 0)
  76. info = ((WebInvokeAttribute) atts [0]).Info;
  77. if (info == null)
  78. info = new WebAttributeInfo ();
  79. template = info.BuildUriTemplate (Operation, GetMessageDescription (MessageDirection.Input));
  80. }
  81. public string BodyName { get; set; }
  82. public WebHttpBehavior Behavior {
  83. get { return behavior; }
  84. }
  85. public WebAttributeInfo Info {
  86. get { return info; }
  87. }
  88. public WebMessageBodyStyle BodyStyle {
  89. get { return info.IsBodyStyleSetExplicitly ? info.BodyStyle : behavior.DefaultBodyStyle; }
  90. }
  91. public bool IsRequestBodyWrapped {
  92. get {
  93. switch (BodyStyle) {
  94. case WebMessageBodyStyle.Wrapped:
  95. case WebMessageBodyStyle.WrappedRequest:
  96. return true;
  97. }
  98. return BodyName != null;
  99. }
  100. }
  101. public bool IsResponseBodyWrapped {
  102. get {
  103. switch (BodyStyle) {
  104. case WebMessageBodyStyle.Wrapped:
  105. case WebMessageBodyStyle.WrappedResponse:
  106. return true;
  107. }
  108. return BodyName != null;
  109. }
  110. }
  111. public OperationDescription Operation {
  112. get { return operation; }
  113. }
  114. public QueryStringConverter Converter {
  115. get { return converter; }
  116. }
  117. public ServiceEndpoint Endpoint {
  118. get { return endpoint; }
  119. }
  120. public UriTemplate UriTemplate {
  121. get { return template; }
  122. }
  123. protected WebContentFormat ToContentFormat (WebMessageFormat src, object result)
  124. {
  125. if (result is Stream)
  126. return WebContentFormat.Raw;
  127. switch (src) {
  128. case WebMessageFormat.Xml:
  129. return WebContentFormat.Xml;
  130. case WebMessageFormat.Json:
  131. return WebContentFormat.Json;
  132. }
  133. throw new SystemException ("INTERNAL ERROR: should not happen");
  134. }
  135. protected string GetMediaTypeString (WebContentFormat fmt)
  136. {
  137. switch (fmt) {
  138. case WebContentFormat.Raw:
  139. return "application/octet-stream";
  140. case WebContentFormat.Json:
  141. return "application/json";
  142. case WebContentFormat.Xml:
  143. default:
  144. return "application/xml";
  145. }
  146. }
  147. protected void CheckMessageVersion (MessageVersion messageVersion)
  148. {
  149. if (messageVersion == null)
  150. throw new ArgumentNullException ("messageVersion");
  151. if (!MessageVersion.None.Equals (messageVersion))
  152. throw new ArgumentException (String.Format ("Only MessageVersion.None is supported. {0} is not.", messageVersion));
  153. }
  154. protected MessageDescription GetMessageDescription (MessageDirection dir)
  155. {
  156. foreach (MessageDescription md in operation.Messages)
  157. if (md.Direction == dir)
  158. return md;
  159. throw new SystemException ("INTERNAL ERROR: no corresponding message description for the specified direction: " + dir);
  160. }
  161. protected XmlObjectSerializer GetSerializer (WebContentFormat msgfmt, bool isWrapped, MessagePartDescription part)
  162. {
  163. switch (msgfmt) {
  164. case WebContentFormat.Xml:
  165. if (xml_serializer == null)
  166. xml_serializer = isWrapped ? new DataContractSerializer (part.Type, part.Name, part.Namespace) : new DataContractSerializer (part.Type);
  167. return xml_serializer;
  168. case WebContentFormat.Json:
  169. // FIXME: after name argument they are hack
  170. if (json_serializer == null)
  171. #if MOONLIGHT
  172. json_serializer = new DataContractJsonSerializer (part.Type);
  173. #else
  174. json_serializer = isWrapped ? new DataContractJsonSerializer (part.Type, BodyName ?? part.Name, null, 0x100000, false, null, true) : new DataContractJsonSerializer (part.Type);
  175. #endif
  176. return json_serializer;
  177. default:
  178. throw new NotImplementedException (msgfmt.ToString ());
  179. }
  180. }
  181. XmlObjectSerializer xml_serializer, json_serializer;
  182. protected object DeserializeObject (XmlObjectSerializer serializer, Message message, MessageDescription md, bool isWrapped, WebContentFormat fmt)
  183. {
  184. // FIXME: handle ref/out parameters
  185. var reader = message.GetReaderAtBodyContents ();
  186. if (isWrapped) {
  187. if (fmt == WebContentFormat.Json)
  188. reader.ReadStartElement ("root", String.Empty); // note that the wrapper name is passed to the serializer.
  189. else
  190. reader.ReadStartElement (md.Body.WrapperName, md.Body.WrapperNamespace);
  191. }
  192. var ret = ReadObjectBody (serializer, reader);
  193. if (isWrapped)
  194. reader.ReadEndElement ();
  195. return ret;
  196. }
  197. protected object ReadObjectBody (XmlObjectSerializer serializer, XmlReader reader)
  198. {
  199. #if NET_2_1
  200. return (serializer is DataContractJsonSerializer) ?
  201. ((DataContractJsonSerializer) serializer).ReadObject (reader) :
  202. ((DataContractSerializer) serializer).ReadObject (reader, true);
  203. #else
  204. return serializer.ReadObject (reader, true);
  205. #endif
  206. }
  207. internal class RequestClientFormatter : WebClientMessageFormatter
  208. {
  209. public RequestClientFormatter (OperationDescription operation, ServiceEndpoint endpoint, QueryStringConverter converter, WebHttpBehavior behavior)
  210. : base (operation, endpoint, converter, behavior)
  211. {
  212. }
  213. public override object DeserializeReply (Message message, object [] parameters)
  214. {
  215. throw new NotSupportedException ();
  216. }
  217. }
  218. internal class ReplyClientFormatter : WebClientMessageFormatter
  219. {
  220. public ReplyClientFormatter (OperationDescription operation, ServiceEndpoint endpoint, QueryStringConverter converter, WebHttpBehavior behavior)
  221. : base (operation, endpoint, converter, behavior)
  222. {
  223. }
  224. public override Message SerializeRequest (MessageVersion messageVersion, object [] parameters)
  225. {
  226. throw new NotSupportedException ();
  227. }
  228. }
  229. #if !NET_2_1
  230. internal class RequestDispatchFormatter : WebDispatchMessageFormatter
  231. {
  232. public RequestDispatchFormatter (OperationDescription operation, ServiceEndpoint endpoint, QueryStringConverter converter, WebHttpBehavior behavior)
  233. : base (operation, endpoint, converter, behavior)
  234. {
  235. }
  236. public override Message SerializeReply (MessageVersion messageVersion, object [] parameters, object result)
  237. {
  238. throw new NotSupportedException ();
  239. }
  240. }
  241. internal class ReplyDispatchFormatter : WebDispatchMessageFormatter
  242. {
  243. public ReplyDispatchFormatter (OperationDescription operation, ServiceEndpoint endpoint, QueryStringConverter converter, WebHttpBehavior behavior)
  244. : base (operation, endpoint, converter, behavior)
  245. {
  246. }
  247. public override void DeserializeRequest (Message message, object [] parameters)
  248. {
  249. throw new NotSupportedException ();
  250. }
  251. }
  252. #endif
  253. internal abstract class WebClientMessageFormatter : WebMessageFormatter, IClientMessageFormatter
  254. {
  255. protected WebClientMessageFormatter (OperationDescription operation, ServiceEndpoint endpoint, QueryStringConverter converter, WebHttpBehavior behavior)
  256. : base (operation, endpoint, converter, behavior)
  257. {
  258. }
  259. public virtual Message SerializeRequest (MessageVersion messageVersion, object [] parameters)
  260. {
  261. if (parameters == null)
  262. throw new ArgumentNullException ("parameters");
  263. CheckMessageVersion (messageVersion);
  264. var c = new Dictionary<string,string> ();
  265. MessageDescription md = GetMessageDescription (MessageDirection.Input);
  266. if (parameters.Length != md.Body.Parts.Count)
  267. throw new ArgumentException ("Parameter array length does not match the number of message body parts");
  268. object msgpart = null;
  269. for (int i = 0; i < parameters.Length; i++) {
  270. var p = md.Body.Parts [i];
  271. string name = p.Name.ToUpper (CultureInfo.InvariantCulture);
  272. if (UriTemplate.PathSegmentVariableNames.Contains (name) ||
  273. UriTemplate.QueryValueVariableNames.Contains (name))
  274. c.Add (name, parameters [i] != null ? Converter.ConvertValueToString (parameters [i], parameters [i].GetType ()) : null);
  275. else {
  276. // FIXME: bind as a message part
  277. if (msgpart == null)
  278. msgpart = parameters [i];
  279. else
  280. throw new NotImplementedException (String.Format ("More than one parameters including {0} that are not contained in the URI template {1} was found.", p.Name, UriTemplate));
  281. }
  282. }
  283. Uri to = UriTemplate.BindByName (Endpoint.Address.Uri, c);
  284. Message ret = Message.CreateMessage (messageVersion, (string) null, msgpart);
  285. ret.Headers.To = to;
  286. var hp = new HttpRequestMessageProperty ();
  287. hp.Method = Info.Method;
  288. WebMessageFormat msgfmt = Info.IsResponseFormatSetExplicitly ? Info.ResponseFormat : Behavior.DefaultOutgoingResponseFormat;
  289. var contentFormat = ToContentFormat (msgfmt, msgpart);
  290. string mediaType = GetMediaTypeString (contentFormat);
  291. // FIXME: get encoding from somewhere
  292. hp.Headers ["Content-Type"] = mediaType + "; charset=utf-8";
  293. #if !NET_2_1
  294. if (WebOperationContext.Current != null)
  295. WebOperationContext.Current.OutgoingRequest.Apply (hp);
  296. #endif
  297. // FIXME: set hp.SuppressEntityBody for some cases.
  298. ret.Properties.Add (HttpRequestMessageProperty.Name, hp);
  299. var wp = new WebBodyFormatMessageProperty (ToContentFormat (Info.IsRequestFormatSetExplicitly ? Info.RequestFormat : Behavior.DefaultOutgoingRequestFormat, null));
  300. ret.Properties.Add (WebBodyFormatMessageProperty.Name, wp);
  301. return ret;
  302. }
  303. public virtual object DeserializeReply (Message message, object [] parameters)
  304. {
  305. if (parameters == null)
  306. throw new ArgumentNullException ("parameters");
  307. CheckMessageVersion (message.Version);
  308. if (message.IsEmpty)
  309. return null; // empty message, could be returned by HttpReplyChannel.
  310. string pname = WebBodyFormatMessageProperty.Name;
  311. if (!message.Properties.ContainsKey (pname))
  312. throw new SystemException ("INTERNAL ERROR: it expects WebBodyFormatMessageProperty existence");
  313. var wp = (WebBodyFormatMessageProperty) message.Properties [pname];
  314. var fmt = wp != null ? wp.Format : WebContentFormat.Xml;
  315. var md = GetMessageDescription (MessageDirection.Output);
  316. var serializer = GetSerializer (wp.Format, IsResponseBodyWrapped, md.Body.ReturnValue);
  317. var ret = DeserializeObject (serializer, message, md, IsResponseBodyWrapped, fmt);
  318. return ret;
  319. }
  320. }
  321. internal class WrappedBodyWriter : BodyWriter
  322. {
  323. public WrappedBodyWriter (object value, XmlObjectSerializer serializer, string name, string ns, WebContentFormat fmt)
  324. : base (true)
  325. {
  326. this.name = name;
  327. this.ns = ns;
  328. this.value = value;
  329. this.serializer = serializer;
  330. this.fmt = fmt;
  331. }
  332. WebContentFormat fmt;
  333. string name, ns;
  334. object value;
  335. XmlObjectSerializer serializer;
  336. #if !NET_2_1
  337. protected override BodyWriter OnCreateBufferedCopy (int maxBufferSize)
  338. {
  339. return new WrappedBodyWriter (value, serializer, name, ns, fmt);
  340. }
  341. #endif
  342. protected override void OnWriteBodyContents (XmlDictionaryWriter writer)
  343. {
  344. switch (fmt) {
  345. case WebContentFormat.Raw:
  346. WriteRawContents (writer);
  347. break;
  348. case WebContentFormat.Json:
  349. WriteJsonBodyContents (writer);
  350. break;
  351. case WebContentFormat.Xml:
  352. WriteXmlBodyContents (writer);
  353. break;
  354. }
  355. }
  356. void WriteRawContents (XmlDictionaryWriter writer)
  357. {
  358. throw new NotSupportedException ("Some unsupported sequence of writing operation occured. It is likely a missing feature.");
  359. }
  360. void WriteJsonBodyContents (XmlDictionaryWriter writer)
  361. {
  362. if (name != null) {
  363. writer.WriteStartElement ("root");
  364. writer.WriteAttributeString ("type", "object");
  365. }
  366. WriteObject (serializer, writer, value);
  367. if (name != null)
  368. writer.WriteEndElement ();
  369. }
  370. void WriteXmlBodyContents (XmlDictionaryWriter writer)
  371. {
  372. if (name != null)
  373. writer.WriteStartElement (name, ns);
  374. WriteObject (serializer, writer, value);
  375. if (name != null)
  376. writer.WriteEndElement ();
  377. }
  378. void WriteObject (XmlObjectSerializer serializer, XmlDictionaryWriter writer, object value)
  379. {
  380. #if NET_2_1
  381. if (serializer is DataContractJsonSerializer)
  382. ((DataContractJsonSerializer) serializer).WriteObject (writer, value);
  383. else
  384. ((DataContractSerializer) serializer).WriteObject (writer, value);
  385. #else
  386. serializer.WriteObject (writer, value);
  387. #endif
  388. }
  389. }
  390. #if !NET_2_1
  391. internal abstract class WebDispatchMessageFormatter : WebMessageFormatter, IDispatchMessageFormatter
  392. {
  393. protected WebDispatchMessageFormatter (OperationDescription operation, ServiceEndpoint endpoint, QueryStringConverter converter, WebHttpBehavior behavior)
  394. : base (operation, endpoint, converter, behavior)
  395. {
  396. }
  397. public virtual Message SerializeReply (MessageVersion messageVersion, object [] parameters, object result)
  398. {
  399. try {
  400. return SerializeReplyCore (messageVersion, parameters, result);
  401. } finally {
  402. if (WebOperationContext.Current != null)
  403. OperationContext.Current.Extensions.Remove (WebOperationContext.Current);
  404. }
  405. }
  406. Message SerializeReplyCore (MessageVersion messageVersion, object [] parameters, object result)
  407. {
  408. // parameters could be null.
  409. // result could be null. For Raw output, it becomes no output.
  410. CheckMessageVersion (messageVersion);
  411. MessageDescription md = GetMessageDescription (MessageDirection.Output);
  412. // FIXME: use them.
  413. // var dcob = Operation.Behaviors.Find<DataContractSerializerOperationBehavior> ();
  414. // XmlObjectSerializer xos = dcob.CreateSerializer (result.GetType (), md.Body.WrapperName, md.Body.WrapperNamespace, null);
  415. // var xsob = Operation.Behaviors.Find<XmlSerializerOperationBehavior> ();
  416. // XmlSerializer [] serializers = XmlSerializer.FromMappings (xsob.GetXmlMappings ().ToArray ());
  417. WebMessageFormat msgfmt = Info.IsResponseFormatSetExplicitly ? Info.ResponseFormat : Behavior.DefaultOutgoingResponseFormat;
  418. XmlObjectSerializer serializer = null;
  419. // FIXME: serialize ref/out parameters as well.
  420. string name = null, ns = null;
  421. switch (msgfmt) {
  422. case WebMessageFormat.Xml:
  423. serializer = GetSerializer (WebContentFormat.Xml, IsResponseBodyWrapped, md.Body.ReturnValue);
  424. name = IsResponseBodyWrapped ? md.Body.WrapperName : null;
  425. ns = IsResponseBodyWrapped ? md.Body.WrapperNamespace : null;
  426. break;
  427. case WebMessageFormat.Json:
  428. serializer = GetSerializer (WebContentFormat.Json, IsResponseBodyWrapped, md.Body.ReturnValue);
  429. name = IsResponseBodyWrapped ? (BodyName ?? md.Body.ReturnValue.Name) : null;
  430. ns = String.Empty;
  431. break;
  432. }
  433. var contentFormat = ToContentFormat (msgfmt, result);
  434. string mediaType = GetMediaTypeString (contentFormat);
  435. Message ret = contentFormat == WebContentFormat.Raw ? new RawMessage ((Stream) result) : Message.CreateMessage (MessageVersion.None, null, new WrappedBodyWriter (result, serializer, name, ns, contentFormat));
  436. // Message properties
  437. var hp = new HttpResponseMessageProperty ();
  438. // FIXME: get encoding from somewhere
  439. hp.Headers ["Content-Type"] = mediaType + "; charset=utf-8";
  440. // apply user-customized HTTP results via WebOperationContext.
  441. if (WebOperationContext.Current != null) // this formatter must be available outside ServiceHost.
  442. WebOperationContext.Current.OutgoingResponse.Apply (hp);
  443. // FIXME: fill some properties if required.
  444. ret.Properties.Add (HttpResponseMessageProperty.Name, hp);
  445. var wp = new WebBodyFormatMessageProperty (contentFormat);
  446. ret.Properties.Add (WebBodyFormatMessageProperty.Name, wp);
  447. return ret;
  448. }
  449. public virtual void DeserializeRequest (Message message, object [] parameters)
  450. {
  451. if (parameters == null)
  452. throw new ArgumentNullException ("parameters");
  453. CheckMessageVersion (message.Version);
  454. IncomingWebRequestContext iwc = null;
  455. if (OperationContext.Current != null) {
  456. OperationContext.Current.Extensions.Add (new WebOperationContext (OperationContext.Current));
  457. iwc = WebOperationContext.Current.IncomingRequest;
  458. }
  459. var wp = message.Properties [WebBodyFormatMessageProperty.Name] as WebBodyFormatMessageProperty;
  460. var fmt = wp != null ? wp.Format : WebContentFormat.Xml;
  461. if (fmt == WebContentFormat.Raw) {
  462. var rmsg = (RawMessage) message;
  463. parameters [0] = rmsg.Stream;
  464. return;
  465. }
  466. Uri to = message.Headers.To;
  467. UriTemplateMatch match = UriTemplate.Match (Endpoint.Address.Uri, to);
  468. if (match == null)
  469. // not sure if it could happen
  470. throw new SystemException (String.Format ("INTERNAL ERROR: UriTemplate does not match with the request: {0} / {1}", UriTemplate, to));
  471. if (iwc != null)
  472. iwc.UriTemplateMatch = match;
  473. MessageDescription md = GetMessageDescription (MessageDirection.Input);
  474. for (int i = 0; i < parameters.Length; i++) {
  475. var p = md.Body.Parts [i];
  476. string name = p.Name.ToUpperInvariant ();
  477. var str = match.BoundVariables [name];
  478. if (str != null)
  479. parameters [i] = Converter.ConvertStringToValue (str, p.Type);
  480. else {
  481. var serializer = GetSerializer (fmt, IsRequestBodyWrapped, p);
  482. parameters [i] = DeserializeObject (serializer, message, md, IsRequestBodyWrapped, fmt);
  483. }
  484. }
  485. }
  486. }
  487. #endif
  488. internal class RawMessage : Message
  489. {
  490. public RawMessage (Stream stream)
  491. {
  492. this.Stream = stream;
  493. headers = new MessageHeaders (MessageVersion.None);
  494. properties = new MessageProperties ();
  495. }
  496. public override MessageVersion Version {
  497. get { return MessageVersion.None; }
  498. }
  499. MessageHeaders headers;
  500. public override MessageHeaders Headers {
  501. get { return headers; }
  502. }
  503. MessageProperties properties;
  504. public override MessageProperties Properties {
  505. get { return properties; }
  506. }
  507. public Stream Stream { get; private set; }
  508. protected override void OnWriteBodyContents (XmlDictionaryWriter writer)
  509. {
  510. throw new NotSupportedException ();
  511. }
  512. }
  513. }
  514. }