Ejemplo n.º 1
0
        private Stream EndProcessRequest(IAsyncResult result)
        {
            MemoryStream ostrm = new MemoryStream();

            try {
                if (m_callback != null)
                {
                    IServiceResponse response = m_callback.EndProcessRequest(result);

                    string contentType = WebOperationContext.Current.IncomingRequest.ContentType;

                    if (contentType == "application/octet-stream")
                    {
                        BinaryEncoder encoder = new BinaryEncoder(ostrm, this.m_quotas.MessageContext);
                        encoder.EncodeMessage(response);
                    }
                    else
                    {
                        HttpsTransportChannel.WriteSoapMessage(
                            ostrm,
                            response.GetType().Name,
                            response,
                            this.m_quotas.MessageContext);
                    }

                    ostrm.Position = 0;
                }
            } catch (Exception e) {
                Utils.Trace(e, "TCPLISTENER - Unexpected error sending result.");
            }

            return(ostrm);
        }