public void AsyncProcessResponse(IServerResponseChannelSinkStack sinkStack, object state, IMessage msg, ITransportHeaders headers, Stream stream) { ITransportHeaders responseHeaders = new TransportHeaders(); if (sinkStack != null) { stream = sinkStack.GetResponseStream(msg, responseHeaders); } if (stream == null) { stream = new MemoryStream(); } SoapMessageFormatter soapMsgFormatter = (SoapMessageFormatter)state; SoapMessage soapMessage = (SoapMessage)soapMsgFormatter.BuildSoapMessageFromMethodResponse((IMethodReturnMessage)msg, out responseHeaders); _soapCore.Serializer.Serialize(stream, soapMessage, null); if (stream is MemoryStream) { stream.Position = 0; } sinkStack.AsyncProcessResponse(msg, responseHeaders, stream); }
private void SerializeResponse(IServerResponseChannelSinkStack sinkStack, IMessage msg, ref ITransportHeaders headers, out Stream stream) { bool usingLocallyCreatedMemoryStream = false; // Does this section do anything useful since we can't use BaseTransportHeaders?? TransportHeaders transportHeaders = new TransportHeaders(); if (headers != null) { foreach (DictionaryEntry entry in headers) { transportHeaders[entry.Key] = entry.Value; } } headers = transportHeaders; // Request a stream into which the serialized message will go stream = sinkStack.GetResponseStream(msg, headers); // None found so create a memory stream (would normally be a ChunkedMemoryStream but that is inaccessible) if (stream == null) { stream = new MemoryStream(); usingLocallyCreatedMemoryStream = true; } // Serialize the message - normally done by CoreChannel.SerializeBinaryMessage(msg, stream, this._includeVersioning); CreateFormatter(true).Serialize(stream, msg, null); // Rewind the stream if ours if (usingLocallyCreatedMemoryStream) { stream.Position = 0; } }
} // AsyncProcessResponse private void SerializeResponse(IServerResponseChannelSinkStack sinkStack, IMessage msg, bool bClientIsClr, ref ITransportHeaders headers, out Stream stream) { BaseTransportHeaders responseHeaders = new BaseTransportHeaders(); if (headers != null) { // copy old headers into new headers foreach (DictionaryEntry entry in headers) { responseHeaders[entry.Key] = entry.Value; } } headers = responseHeaders; responseHeaders.ContentType = CoreChannel.SOAPContentType; if (_protocol == Protocol.Http) { // check to see if an exception occurred (requires special status code for HTTP) IMethodReturnMessage mrm = msg as IMethodReturnMessage; if ((mrm != null) && (mrm.Exception != null)) { headers["__HttpStatusCode"] = "500"; headers["__HttpReasonPhrase"] = "Internal Server Error"; } } bool bMemStream = false; stream = sinkStack.GetResponseStream(msg, headers); if (stream == null) { stream = new ChunkedMemoryStream(CoreChannel.BufferPool); bMemStream = true; } bool bBashUrl = CoreChannel.SetupUrlBashingForIisSslIfNecessary(); CallContext.SetData("__ClientIsClr", bClientIsClr); try { CoreChannel.SerializeSoapMessage(msg, stream, _includeVersioning); } finally { CallContext.FreeNamedDataSlot("__ClientIsClr"); CoreChannel.CleanupUrlBashingForIisSslIfNecessary(bBashUrl); } if (bMemStream) { stream.Position = 0; } } // SerializeResponse
private Stream GetResponseStreamFor(IServerResponseChannelSinkStack sinkStack, IMessage responseMsg, ITransportHeaders headers) { Stream stream = sinkStack.GetResponseStream(responseMsg, headers); if (stream == null) { // the previous stream-handling sinks delegated the decision to which stream the message should be serialised to this sink stream = new MemoryStream(); // create a new stream } return(stream); }
public void AsyncProcessResponse (IServerResponseChannelSinkStack sinkStack, object state, IMessage message, ITransportHeaders headers, Stream stream) { ITransportHeaders responseHeaders = new TransportHeaders(); if (sinkStack != null) stream = sinkStack.GetResponseStream (message, responseHeaders); if (stream == null) stream = new MemoryStream(); _binaryCore.Serializer.Serialize (stream, message, null); if (stream is MemoryStream) stream.Position = 0; sinkStack.AsyncProcessResponse (message, responseHeaders, stream); }
private static void SerializeResponseMessage(IServerResponseChannelSinkStack sinkStack , IMessage responseMsg , ref ITransportHeaders responseHeaders , ref Stream responseStream) { if (sinkStack == null) { throw new ArgumentNullException("sinkStack"); } if (responseMsg == null) { throw new ArgumentNullException("responseMsg"); } var methodReturnMessage = responseMsg as IMethodReturnMessage; if (methodReturnMessage == null) { throw new ArgumentException(string.Format( "Invalid response message type: '{0}'.", responseMsg.GetType()), "responseMsg"); } if (responseHeaders == null) { responseHeaders = new TransportHeaders(); } bool shouldRewindStream = false; if (responseStream == null) { responseStream = sinkStack.GetResponseStream(responseMsg, responseHeaders); if (responseStream == null) { responseStream = new MemoryStream(); shouldRewindStream = true; } } var m = new JsonMessage(); m.Return = methodReturnMessage.ReturnValue; m.Exception = methodReturnMessage.Exception; JSONSerializer.Serialize(responseStream, m, typeof(JsonMessage)); if (shouldRewindStream) { responseStream.Position = 0; } }
} // AsyncProcessResponse private void SerializeResponse(IServerResponseChannelSinkStack sinkStack, IMessage msg, ref ITransportHeaders headers, out Stream stream) { BaseTransportHeaders responseHeaders = new BaseTransportHeaders(); if (headers != null) { // copy old headers into new headers foreach (DictionaryEntry entry in headers) { responseHeaders[entry.Key] = entry.Value; } } headers = responseHeaders; if (_protocol == Protocol.Http) { responseHeaders.ContentType = CoreChannel.BinaryMimeType; } bool bMemStream = false; stream = sinkStack.GetResponseStream(msg, headers); if (stream == null) { stream = new ChunkedMemoryStream(CoreChannel.BufferPool); bMemStream = true; } bool bBashUrl = CoreChannel.SetupUrlBashingForIisSslIfNecessary(); try { CallContext.SetData("__ClientIsClr", true); CoreChannel.SerializeBinaryMessage(msg, stream, _includeVersioning); } finally { CallContext.FreeNamedDataSlot("__ClientIsClr"); CoreChannel.CleanupUrlBashingForIisSslIfNecessary(bBashUrl); } if (bMemStream) { stream.Position = 0; } } // SerializeResponse
private void SerializeResponse(IServerResponseChannelSinkStack sinkStack, IMessage msg, bool bClientIsClr, ref ITransportHeaders headers, out Stream stream) { BaseTransportHeaders headers2 = new BaseTransportHeaders(); if (headers != null) { foreach (DictionaryEntry entry in headers) { headers2[entry.Key] = entry.Value; } } headers = headers2; headers2.ContentType = "text/xml; charset=\"utf-8\""; if (this._protocol == Protocol.Http) { IMethodReturnMessage message = msg as IMethodReturnMessage; if ((message != null) && (message.Exception != null)) { headers["__HttpStatusCode"] = "500"; headers["__HttpReasonPhrase"] = "Internal Server Error"; } } bool flag = false; stream = sinkStack.GetResponseStream(msg, headers); if (stream == null) { stream = new ChunkedMemoryStream(CoreChannel.BufferPool); flag = true; } bool bBashedUrl = CoreChannel.SetupUrlBashingForIisSslIfNecessary(); CallContext.SetData("__ClientIsClr", bClientIsClr); try { CoreChannel.SerializeSoapMessage(msg, stream, this._includeVersioning); } finally { CallContext.FreeNamedDataSlot("__ClientIsClr"); CoreChannel.CleanupUrlBashingForIisSslIfNecessary(bBashedUrl); } if (flag) { stream.Position = 0L; } }
public void AsyncProcessResponse(IServerResponseChannelSinkStack sinkStack, object state, IMessage message, ITransportHeaders headers, Stream stream) { ITransportHeaders transportHeader = new TransportHeaders(); if (sinkStack != null) { stream = sinkStack.GetResponseStream(message, transportHeader); } if (stream == null) { stream = new MemoryStream(); } this._binaryCore.Serializer.Serialize(stream, message, null); if (stream is MemoryStream) { stream.Position = (long)0; } sinkStack.AsyncProcessResponse(message, transportHeader, stream); }
private void SerializeResponse(IServerResponseChannelSinkStack sinkStack, IMessage msg, ref ITransportHeaders headers, out Stream stream) { BaseTransportHeaders headers2 = new BaseTransportHeaders(); if (headers != null) { foreach (DictionaryEntry entry in headers) { headers2[entry.Key] = entry.Value; } } headers = headers2; if (this._protocol == Protocol.Http) { headers2.ContentType = "application/octet-stream"; } bool flag = false; stream = sinkStack.GetResponseStream(msg, headers); if (stream == null) { stream = new ChunkedMemoryStream(CoreChannel.BufferPool); flag = true; } bool bBashedUrl = CoreChannel.SetupUrlBashingForIisSslIfNecessary(); try { CallContext.SetData("__ClientIsClr", true); CoreChannel.SerializeBinaryMessage(msg, stream, this._includeVersioning); } finally { CallContext.FreeNamedDataSlot("__ClientIsClr"); CoreChannel.CleanupUrlBashingForIisSslIfNecessary(bBashedUrl); } if (flag) { stream.Position = 0L; } }
public void AsyncProcessResponse(IServerResponseChannelSinkStack sinkStack, object state, IMessage msg, ITransportHeaders headers, Stream stream) { ITransportHeaders responseHeaders = new TransportHeaders(); if (sinkStack != null) { stream = sinkStack.GetResponseStream(msg, responseHeaders); } if (stream == null) { stream = new MemoryStream(); } _binaryCore.Serializer.Serialize(stream, msg, null); if (stream is MemoryStream) { stream.Position = 0; } sinkStack.AsyncProcessResponse(msg, responseHeaders, stream); }
private void GenerateSdl(SdlType sdlType, IServerResponseChannelSinkStack sinkStack, ITransportHeaders requestHeaders, ITransportHeaders responseHeaders, out Stream outputStream) { if (!this.MetadataEnabled) { throw new RemotingException(CoreChannel.GetResourceString("Remoting_MetadataNotEnabled")); } string uri = requestHeaders["__RequestUri"] as string; string objectUriFromRequestUri = HttpChannelHelper.GetObjectUriFromRequestUri(uri); if (!this.RemoteApplicationMetadataEnabled && (string.Compare(objectUriFromRequestUri, "RemoteApplicationMetadata.rem", StringComparison.OrdinalIgnoreCase) == 0)) { throw new RemotingException(CoreChannel.GetResourceString("Remoting_RemoteApplicationMetadataNotEnabled")); } string hostName = (string) requestHeaders["Host"]; if (hostName != null) { int index = hostName.IndexOf(':'); if (index != -1) { hostName = hostName.Substring(0, index); } } string channelUri = SetupUrlBashingForIisIfNecessary(hostName); ServiceType[] serviceTypes = null; if (string.Compare(objectUriFromRequestUri, "RemoteApplicationMetadata.rem", StringComparison.OrdinalIgnoreCase) == 0) { ActivatedServiceTypeEntry[] registeredActivatedServiceTypes = RemotingConfiguration.GetRegisteredActivatedServiceTypes(); WellKnownServiceTypeEntry[] registeredWellKnownServiceTypes = RemotingConfiguration.GetRegisteredWellKnownServiceTypes(); int num2 = 0; if (registeredActivatedServiceTypes != null) { num2 += registeredActivatedServiceTypes.Length; } if (registeredWellKnownServiceTypes != null) { num2 += registeredWellKnownServiceTypes.Length; } serviceTypes = new ServiceType[num2]; int num3 = 0; if (registeredActivatedServiceTypes != null) { foreach (ActivatedServiceTypeEntry entry in registeredActivatedServiceTypes) { serviceTypes[num3++] = new ServiceType(entry.ObjectType, null); } } if (registeredWellKnownServiceTypes != null) { foreach (WellKnownServiceTypeEntry entry2 in registeredWellKnownServiceTypes) { string url = this._receiver.GetUrlsForUri(entry2.ObjectUri)[0]; if (channelUri != null) { url = HttpChannelHelper.ReplaceChannelUriWithThisString(url, channelUri); } else if (hostName != null) { url = HttpChannelHelper.ReplaceMachineNameWithThisString(url, hostName); } serviceTypes[num3++] = new ServiceType(entry2.ObjectType, url); } } } else { Type serverTypeForUri = RemotingServices.GetServerTypeForUri(objectUriFromRequestUri); if (serverTypeForUri == null) { throw new RemotingException(string.Format(CultureInfo.CurrentCulture, "Object with uri '{0}' does not exist at server.", new object[] { objectUriFromRequestUri })); } string str6 = this._receiver.GetUrlsForUri(objectUriFromRequestUri)[0]; if (channelUri != null) { str6 = HttpChannelHelper.ReplaceChannelUriWithThisString(str6, channelUri); } else if (hostName != null) { str6 = HttpChannelHelper.ReplaceMachineNameWithThisString(str6, hostName); } serviceTypes = new ServiceType[] { new ServiceType(serverTypeForUri, str6) }; } responseHeaders["Content-Type"] = "text/xml"; bool flag = false; outputStream = sinkStack.GetResponseStream(null, responseHeaders); if (outputStream == null) { outputStream = new MemoryStream(0x400); flag = true; } MetaData.ConvertTypesToSchemaToStream(serviceTypes, sdlType, outputStream); if (flag) { outputStream.Position = 0L; } }
private static void SerializeResponseMessage(IServerResponseChannelSinkStack sinkStack , IMessage responseMsg , ref ITransportHeaders responseHeaders , ref Stream responseStream) { if (sinkStack == null) throw new ArgumentNullException("sinkStack"); if (responseMsg == null) throw new ArgumentNullException("responseMsg"); var methodReturnMessage = responseMsg as IMethodReturnMessage; if (methodReturnMessage == null) throw new ArgumentException(string.Format( "Invalid response message type: '{0}'.", responseMsg.GetType()), "responseMsg"); if (responseHeaders == null) responseHeaders = new TransportHeaders(); bool shouldRewindStream = false; if (responseStream == null) { responseStream = sinkStack.GetResponseStream(responseMsg, responseHeaders); if (responseStream == null) { responseStream = new MemoryStream(); shouldRewindStream = true; } } var m = new JsonMessage(); m.Return = methodReturnMessage.ReturnValue; m.Exception = methodReturnMessage.Exception; JSONSerializer.Serialize(responseStream, m, typeof(JsonMessage)); if (shouldRewindStream) { responseStream.Position = 0; } }
} // ShouldIntercept private void GenerateSdl(SdlType sdlType, IServerResponseChannelSinkStack sinkStack, ITransportHeaders requestHeaders, ITransportHeaders responseHeaders, out Stream outputStream) { if (!MetadataEnabled) { throw new RemotingException(CoreChannel.GetResourceString("Remoting_MetadataNotEnabled")); } String requestUri = requestHeaders[CommonTransportKeys.RequestUri] as String; String objectUri = HttpChannelHelper.GetObjectUriFromRequestUri(requestUri); if (!RemoteApplicationMetadataEnabled && (String.Compare(objectUri, "RemoteApplicationMetadata.rem", StringComparison.OrdinalIgnoreCase) == 0)) { throw new RemotingException(CoreChannel.GetResourceString("Remoting_RemoteApplicationMetadataNotEnabled")); } // If the host header is present, we will use this in the generated uri's String hostName = (String)requestHeaders["Host"]; if (hostName != null) { // filter out port number if present int index = hostName.IndexOf(':'); if (index != -1) { hostName = hostName.Substring(0, index); } } ServiceType[] types = null; if (String.Compare(objectUri, "RemoteApplicationMetadata.rem", StringComparison.OrdinalIgnoreCase) == 0) { // get the service description for all registered service types ActivatedServiceTypeEntry[] activatedTypes = RemotingConfiguration.GetRegisteredActivatedServiceTypes(); WellKnownServiceTypeEntry[] wellKnownTypes = RemotingConfiguration.GetRegisteredWellKnownServiceTypes(); // determine total number of types int typeCount = 0; if (activatedTypes != null) { typeCount += activatedTypes.Length; } if (wellKnownTypes != null) { typeCount += wellKnownTypes.Length; } types = new ServiceType[typeCount]; // collect data int co = 0; if (activatedTypes != null) { foreach (ActivatedServiceTypeEntry entry in activatedTypes) { types[co++] = new ServiceType(entry.ObjectType, null); } } if (wellKnownTypes != null) { foreach (WellKnownServiceTypeEntry entry in wellKnownTypes) { String[] urls = _receiver.GetUrlsForUri(entry.ObjectUri); String url = urls[0]; if (hostName != null) { url = HttpChannelHelper.ReplaceMachineNameWithThisString(url, hostName); } types[co++] = new ServiceType(entry.ObjectType, url); } } InternalRemotingServices.RemotingAssert(co == typeCount, "Not all types were processed."); } else { // get the service description for a particular object Type objectType = RemotingServices.GetServerTypeForUri(objectUri); if (objectType == null) { throw new RemotingException( String.Format( CultureInfo.CurrentCulture, "Object with uri '{0}' does not exist at server.", objectUri)); } String[] urls = _receiver.GetUrlsForUri(objectUri); String url = urls[0]; if (hostName != null) { url = HttpChannelHelper.ReplaceMachineNameWithThisString(url, hostName); } types = new ServiceType[1]; types[0] = new ServiceType(objectType, url); } responseHeaders["Content-Type"] = "text/xml"; bool bMemStream = false; outputStream = sinkStack.GetResponseStream(null, responseHeaders); if (outputStream == null) { outputStream = new MemoryStream(1024); bMemStream = true; } MetaData.ConvertTypesToSchemaToStream(types, sdlType, outputStream); if (bMemStream) { outputStream.Position = 0; } } // GenerateXmlForUri
private void SerializeResponse(IServerResponseChannelSinkStack sinkStack, IMessage msg, bool bClientIsClr, ref ITransportHeaders headers, out Stream stream) { BaseTransportHeaders responseHeaders = new BaseTransportHeaders(); if (headers != null) { // copy old headers into new headers foreach (DictionaryEntry entry in headers) { responseHeaders[entry.Key] = entry.Value; } } headers = responseHeaders; responseHeaders.ContentType = CoreChannel.SOAPContentType; if (_protocol == Protocol.Http) { // check to see if an exception occurred (requires special status code for HTTP) IMethodReturnMessage mrm = msg as IMethodReturnMessage; if ((mrm != null) && (mrm.Exception != null)) { headers["__HttpStatusCode"] = "500"; headers["__HttpReasonPhrase"] = "Internal Server Error"; } } bool bMemStream = false; stream = sinkStack.GetResponseStream(msg, headers); if (stream == null) { stream = new ChunkedMemoryStream(CoreChannel.BufferPool); bMemStream = true; } bool bBashUrl = CoreChannel.SetupUrlBashingForIisSslIfNecessary(); CallContext.SetData("__ClientIsClr", bClientIsClr); try { CoreChannel.SerializeSoapMessage(msg, stream, _includeVersioning); } finally { CallContext.FreeNamedDataSlot("__ClientIsClr"); CoreChannel.CleanupUrlBashingForIisSslIfNecessary(bBashUrl); } if (bMemStream) stream.Position = 0; } // SerializeResponse
private Stream GetResponseStreamFor(IServerResponseChannelSinkStack sinkStack, IMessage responseMsg, ITransportHeaders headers) { Stream stream = sinkStack.GetResponseStream(responseMsg, headers); if (stream == null) { // the previous stream-handling sinks delegated the decision to which stream the message should be serialised to this sink stream = new MemoryStream(); // create a new stream } return stream; }
private static void SerializeResponseMessage(IServerResponseChannelSinkStack sinkStack , IMessage responseMsg , ref ITransportHeaders responseHeaders , ref Stream responseStream) { if (sinkStack == null) throw new ArgumentNullException("sinkStack"); if (responseMsg == null) throw new ArgumentNullException("responseMsg"); var methodReturnMessage = responseMsg as IMethodReturnMessage; if (methodReturnMessage == null) throw new ArgumentException(string.Format( "Invalid response message type: '{0}'.", responseMsg.GetType()), "responseMsg"); if (responseHeaders == null) responseHeaders = new TransportHeaders(); bool shouldRewindStream = false; if (responseStream == null) { responseStream = sinkStack.GetResponseStream(responseMsg, responseHeaders); if (responseStream == null) { responseStream = new MemoryStream(); shouldRewindStream = true; } } byte[] data = _serializer.SerializeMethodReturn(new MethodReturn() { Exception = methodReturnMessage.Exception, ReturnValue = methodReturnMessage.ReturnValue }); responseStream.Write(data, 0, data.Length); if (shouldRewindStream) { responseStream.Position = 0; } }
public void AsyncProcessResponse (IServerResponseChannelSinkStack sinkStack, object state, IMessage msg, ITransportHeaders headers, Stream stream) { ITransportHeaders responseHeaders = new TransportHeaders(); if(sinkStack != null) stream = sinkStack.GetResponseStream(msg, responseHeaders); if(stream == null) stream = new MemoryStream(); SoapMessageFormatter soapMsgFormatter = (SoapMessageFormatter)state; SoapMessage soapMessage = (SoapMessage) soapMsgFormatter.BuildSoapMessageFromMethodResponse((IMethodReturnMessage)msg, out responseHeaders); _soapCore.Serializer.Serialize(stream, soapMessage, null); if(stream is MemoryStream) stream.Position = 0; sinkStack.AsyncProcessResponse (msg, responseHeaders, stream); }
} // ShouldIntercept private void GenerateSdl(SdlType sdlType, IServerResponseChannelSinkStack sinkStack, ITransportHeaders requestHeaders, ITransportHeaders responseHeaders, out Stream outputStream) { if (!MetadataEnabled) throw new RemotingException(CoreChannel.GetResourceString("Remoting_MetadataNotEnabled")); String requestUri = requestHeaders[CommonTransportKeys.RequestUri] as String; String objectUri = HttpChannelHelper.GetObjectUriFromRequestUri(requestUri); if (!RemoteApplicationMetadataEnabled && (String.Compare(objectUri, "RemoteApplicationMetadata.rem", StringComparison.OrdinalIgnoreCase) == 0)) throw new RemotingException(CoreChannel.GetResourceString("Remoting_RemoteApplicationMetadataNotEnabled")); // If the host header is present, we will use this in the generated uri's String hostName = (String)requestHeaders["Host"]; if (hostName != null) { // filter out port number if present int index = hostName.IndexOf(':'); if (index != -1) hostName = hostName.Substring(0, index); } ServiceType[] types = null; if (String.Compare(objectUri, "RemoteApplicationMetadata.rem", StringComparison.OrdinalIgnoreCase) == 0) { // get the service description for all registered service types ActivatedServiceTypeEntry[] activatedTypes = RemotingConfiguration.GetRegisteredActivatedServiceTypes(); WellKnownServiceTypeEntry[] wellKnownTypes = RemotingConfiguration.GetRegisteredWellKnownServiceTypes(); // determine total number of types int typeCount = 0; if (activatedTypes != null) typeCount += activatedTypes.Length; if (wellKnownTypes != null) typeCount += wellKnownTypes.Length; types = new ServiceType[typeCount]; // collect data int co = 0; if (activatedTypes != null) { foreach (ActivatedServiceTypeEntry entry in activatedTypes) { types[co++] = new ServiceType(entry.ObjectType, null); } } if (wellKnownTypes != null) { foreach (WellKnownServiceTypeEntry entry in wellKnownTypes) { String[] urls = _receiver.GetUrlsForUri(entry.ObjectUri); String url = urls[0]; if (hostName != null) url = HttpChannelHelper.ReplaceMachineNameWithThisString(url, hostName); types[co++] = new ServiceType(entry.ObjectType, url); } } InternalRemotingServices.RemotingAssert(co == typeCount, "Not all types were processed."); } else { // get the service description for a particular object Type objectType = RemotingServices.GetServerTypeForUri(objectUri); if (objectType == null) { throw new RemotingException( String.Format( CultureInfo.CurrentCulture, "Object with uri '{0}' does not exist at server.", objectUri)); } String[] urls = _receiver.GetUrlsForUri(objectUri); String url = urls[0]; if (hostName != null) url = HttpChannelHelper.ReplaceMachineNameWithThisString(url, hostName); types = new ServiceType[1]; types[0] = new ServiceType(objectType, url); } responseHeaders["Content-Type"] = "text/xml"; bool bMemStream = false; outputStream = sinkStack.GetResponseStream(null, responseHeaders); if (outputStream == null) { outputStream = new MemoryStream(1024); bMemStream = true; } MetaData.ConvertTypesToSchemaToStream(types, sdlType, outputStream); if (bMemStream) outputStream.Position = 0; } // GenerateXmlForUri
System.IO.Stream IServerChannelSink.GetResponseStream(IServerResponseChannelSinkStack sinkStack, object state, IMessage msg, ITransportHeaders headers) { return(sinkStack.GetResponseStream(msg, headers)); }
private void SerializeResponse(IServerResponseChannelSinkStack sinkStack, IMessage msg, ref ITransportHeaders headers, out Stream stream) { BaseTransportHeaders responseHeaders = new BaseTransportHeaders(); if (headers != null) { // copy old headers into new headers foreach (DictionaryEntry entry in headers) { responseHeaders[entry.Key] = entry.Value; } } headers = responseHeaders; if (_protocol == Protocol.Http) { responseHeaders.ContentType = CoreChannel.BinaryMimeType; } bool bMemStream = false; stream = sinkStack.GetResponseStream(msg, headers); if (stream == null) { stream = new ChunkedMemoryStream(CoreChannel.BufferPool); bMemStream = true; } bool bBashUrl = CoreChannel.SetupUrlBashingForIisSslIfNecessary(); try { CallContext.SetData("__ClientIsClr", true); CoreChannel.SerializeBinaryMessage(msg, stream, _includeVersioning); } finally { CallContext.FreeNamedDataSlot("__ClientIsClr"); CoreChannel.CleanupUrlBashingForIisSslIfNecessary(bBashUrl); } if (bMemStream) stream.Position = 0; } // SerializeResponse
System.IO.Stream IServerChannelSink.GetResponseStream(IServerResponseChannelSinkStack sinkStack, object state, IMessage msg, ITransportHeaders headers) { return sinkStack.GetResponseStream(msg, headers); }