static Message CreateMessageWithHttpStatusCode(HttpStatusCode httpStatusCode)
        {
            Message replyMessage = Message.CreateMessage(MessageVersion.None, "");

            HttpResponseMessageProperty httpProperty = new HttpResponseMessageProperty();

            httpProperty.StatusCode         = httpStatusCode;
            httpProperty.SuppressEntityBody = true;

            replyMessage.Properties.Add(HttpResponseMessageProperty.Name, httpProperty);
            return(replyMessage);
        }
示例#2
0
            public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
            {
                if (!(error is EndpointNotFoundException))
                {
                    return;
                }
                fault = Message.CreateMessage(version, null);
                var prop = new HttpResponseMessageProperty();

                prop.StatusCode = HttpStatusCode.NotFound;
                fault.Properties.Add(HttpResponseMessageProperty.Name, prop);
            }
示例#3
0
 /// <summary>
 /// Called after the operation has returned but before the reply message is sent.
 /// </summary>
 /// <param name="reply">The reply message. This value is null if the operation is one way.</param>
 /// <param name="correlationState">The correlation object returned from the <see cref="M:System.ServiceModel.Dispatcher.IDispatchMessageInspector.AfterReceiveRequest(System.ServiceModel.Channels.Message@,System.ServiceModel.IClientChannel,System.ServiceModel.InstanceContext)"/> method.</param>
 public void BeforeSendReply(ref Message reply, object correlationState)
 {
     if (reply != null && correlationState == HttpAccessDenied)
     {
         HttpResponseMessageProperty responseProperty = new HttpResponseMessageProperty
         {
             StatusCode = (HttpStatusCode)401
         };
         reply.Properties["httpResponse"] = responseProperty;
     }
     // TODO: else send something :)
 }
示例#4
0
        // Token: 0x06000277 RID: 631 RVA: 0x000109B0 File Offset: 0x0000EBB0
        private static bool Return302RedirectionResponse(OperationContext operationContext, string redirectUrl)
        {
            ExTraceGlobals.AuthenticationTracer.TraceDebug <string>(0L, "Returning a 302 Redirection response to Location: {0}", redirectUrl);
            RequestDetailsLoggerBase <RequestDetailsLogger> .Current.SetRedirectionType(RedirectionType.HttpRedirect);

            HttpResponseMessageProperty httpResponseMessageProperty = AutodiscoverAuthorizationManager.GetHttpResponseMessageProperty(operationContext);

            httpResponseMessageProperty.StatusCode         = HttpStatusCode.Found;
            httpResponseMessageProperty.SuppressEntityBody = true;
            httpResponseMessageProperty.Headers.Add(HttpResponseHeader.Location, redirectUrl);
            return(false);
        }
示例#5
0
            public void BeforeSendReply(ref System.ServiceModel.Channels.Message reply, object correlationState)
            {
                if (reply.IsFault)
                {
                    HttpResponseMessageProperty property = new HttpResponseMessageProperty();

                    // Here the response code is changed to 200.
                    property.StatusCode = System.Net.HttpStatusCode.OK;

                    reply.Properties[HttpResponseMessageProperty.Name] = property;
                }
            }
        public Message CreateEmptyResponse()
        {
            Message response = Message.CreateMessage(MessageVersion.Default, null, (object)null);

            HttpResponseMessageProperty http = new HttpResponseMessageProperty();

            http.StatusCode         = System.Net.HttpStatusCode.OK;
            http.SuppressEntityBody = true;
            response.Properties.Add(HttpResponseMessageProperty.Name, http);

            return(response);
        }
        System.ServiceModel.Channels.Message IRESTLightswitch.GetLightswitchState()
        {
            System.ServiceModel.Channels.Message response = StreamMessageHelper.CreateMessage(OperationContext.Current.IncomingMessageVersion, "GETRESPONSE", this.WriteImageToStream);

            HttpResponseMessageProperty responseProperty = new HttpResponseMessageProperty();

            responseProperty.Headers.Add("Content-Type", "image/jpeg");
            response.Properties.Add(HttpResponseMessageProperty.Name, responseProperty);
            Console.WriteLine("Sent Light switch state to the caller");

            return(response);
        }
        public void BeforeSendReply(ref Message reply, object correlationState)
        {
            if (reply.IsFault)
            {
                var property = new HttpResponseMessageProperty();

                // Here the response code is changed to 200.
                property.StatusCode = HttpStatusCode.OK;

                reply.Properties[HttpResponseMessageProperty.Name] = property;
            }
        }
示例#9
0
        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            BodyWriter bodyWriter = new ErrorBodyWriter(new ErrorDetails(error.Message));

            fault = Message.CreateMessage(version, null, bodyWriter);
            HttpResponseMessageProperty prop = new HttpResponseMessageProperty();

            prop.StatusCode = HttpStatusCode.BadRequest;
            prop.Headers[HttpResponseHeader.ContentType] = "application/xml; charset=utf-8";
            fault.Properties.Add(HttpResponseMessageProperty.Name, prop);
            fault.Properties.Add(WebBodyFormatMessageProperty.Name, new WebBodyFormatMessageProperty(WebContentFormat.Xml));
        }
示例#10
0
        private Message BuildMessage(string jsonStr, MessageVersion messageVersion, object[] parameters, object result)
        {
            byte[]  body         = Encoding.UTF8.GetBytes(jsonStr);
            Message replyMessage = Message.CreateMessage(messageVersion, m_Operation.Messages[1].Action, new RawBodyWriter(body));

            replyMessage.Properties.Add(WebBodyFormatMessageProperty.Name, new WebBodyFormatMessageProperty(WebContentFormat.Raw));
            HttpResponseMessageProperty respProp = new HttpResponseMessageProperty();

            respProp.Headers[HttpResponseHeader.ContentType] = "application/json";
            replyMessage.Properties.Add(HttpResponseMessageProperty.Name, respProp);
            return(replyMessage);
        }
示例#11
0
        private void SetVasaSessionId(Guid sessionId)
        {
            var httpCookie = String.Format("{0}={1}", VASA_SESSION_COOKIE, sessionId);

            var responseMessageProperty = new HttpResponseMessageProperty();

            responseMessageProperty.Headers.Add(HttpResponseHeader.SetCookie, httpCookie);

            OperationContext.Current.OutgoingMessageProperties.Add(HttpResponseMessageProperty.Name, responseMessageProperty);

            _traceSource.TraceEvent(TraceEventType.Information, 0, Properties.Resources.VasaSessionSetSession, VASA_SESSION_COOKIE, sessionId);
        }
示例#12
0
        public Message SerializeReply(MessageVersion messageVersion, object[] parameters, object result)
        {
            var json         = JsonHelper.SerializeToRestJson(result);
            var replyMessage = Message.CreateMessage(messageVersion, _operation.Messages[1].Action, GetBytes(json));

            replyMessage.Properties.Add(WebBodyFormatMessageProperty.Name, new WebBodyFormatMessageProperty(WebContentFormat.Raw));
            var responseProperty = new HttpResponseMessageProperty();

            responseProperty.Headers[HttpResponseHeader.ContentType] = "application/json";
            replyMessage.Properties.Add(HttpResponseMessageProperty.Name, responseProperty);
            return(replyMessage);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="messageVersion"></param>
        /// <param name="parameters"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public Message SerializeReply(MessageVersion messageVersion, object[] parameters, object result)
        {
            byte[]  body         = this.EncodeReply(parameters, result);
            Message replyMessage = Message.CreateMessage(messageVersion, this.Action, new BinaryRawBodyWriter(body));

            replyMessage.Properties.Add(WebBodyFormatMessageProperty.Name, new WebBodyFormatMessageProperty(WebContentFormat.Raw));
            HttpResponseMessageProperty respProp = new HttpResponseMessageProperty();

            respProp.Headers[HttpResponseHeader.ContentType] = "application/json";
            replyMessage.Properties.Add(HttpResponseMessageProperty.Name, respProp);
            return(replyMessage);
        }
示例#14
0
        ///
        /// Get the HttpResponseMessageProperty
        ///
        protected virtual void ApplyHttpResponseSettings(
            ref Message fault, System.Net.HttpStatusCode statusCode,
            string statusDescription)
        {
            var httpResponse = new HttpResponseMessageProperty()
            {
                StatusCode        = statusCode,
                StatusDescription = statusDescription
            };

            fault.Properties.Add(HttpResponseMessageProperty.Name, httpResponse);
        }
示例#15
0
        void WriteHttpProperties(XmlWriter dictionaryWriter)
        {
            Fx.Assert(this.message != null, "");
            object property;

            if (this.message.Properties.TryGetValue(HttpResponseMessageProperty.Name, out property))
            {
                HttpResponseMessageProperty responseProperty = (HttpResponseMessageProperty)property;

                dictionaryWriter.WriteStartElement(MessageLogTraceRecord.HttpResponseMessagePropertyElementName);

                dictionaryWriter.WriteElementString(MessageLogTraceRecord.StatusCodeElementName, responseProperty.StatusCode.ToString());
                if (responseProperty.StatusDescription != null)
                {
                    dictionaryWriter.WriteElementString(MessageLogTraceRecord.StatusDescriptionElementName, responseProperty.StatusDescription);
                }

                dictionaryWriter.WriteStartElement(MessageLogTraceRecord.WebHeadersElementName);
                WebHeaderCollection responseHeaders = responseProperty.Headers;
                for (int i = 0; i < responseHeaders.Count; i++)
                {
                    string name  = responseHeaders.Keys[i];
                    string value = responseHeaders[i];
                    dictionaryWriter.WriteElementString(name, value);
                }
                dictionaryWriter.WriteEndElement(); //

                dictionaryWriter.WriteEndElement(); // </HttpResponseMessageProperty>
            }

            if (this.message.Properties.TryGetValue(HttpRequestMessageProperty.Name, out property))
            {
                HttpRequestMessageProperty requestProperty = (HttpRequestMessageProperty)property;

                dictionaryWriter.WriteStartElement(MessageLogTraceRecord.HttpRequestMessagePropertyElementName);

                dictionaryWriter.WriteElementString(MessageLogTraceRecord.MethodElementName, requestProperty.Method);
                dictionaryWriter.WriteElementString(MessageLogTraceRecord.QueryStringElementName, requestProperty.QueryString);

                dictionaryWriter.WriteStartElement(MessageLogTraceRecord.WebHeadersElementName);
                WebHeaderCollection responseHeaders = requestProperty.Headers;
                for (int i = 0; i < responseHeaders.Count; i++)
                {
                    string name  = responseHeaders.Keys[i];
                    string value = responseHeaders[i];
                    dictionaryWriter.WriteElementString(name, value);
                }
                dictionaryWriter.WriteEndElement(); //

                dictionaryWriter.WriteEndElement(); // </HttpResponseMessageProperty>
            }
        }
        public override void ProcessRequest(ref System.ServiceModel.Channels.RequestContext requestContext)
        {
            Message request = requestContext.RequestMessage;
            HttpRequestMessageProperty requestProp = (HttpRequestMessageProperty)request.Properties[HttpRequestMessageProperty.Name];


            if (bool.Parse(AppSettings.GetAbsolute("CheckSession")) == true)
            {
                Message reply;
                reply = Message.CreateMessage(MessageVersion.None, null);
                HttpResponseMessageProperty responseProp = new HttpResponseMessageProperty()
                {
                    StatusCode = HttpStatusCode.Unauthorized
                };
                if (requestContext == null || requestContext.RequestMessage == null)
                {
                    return;
                }
                NameValueCollection queryParams = HttpUtility.ParseQueryString(requestProp.QueryString);
                if (request.Properties.Via.LocalPath.ToUpper() != LogInMessageAdress.ToUpper())
                {
                    if (requestProp.Headers[SessionHeader] == null)                    //case header not specified
                    {
                        responseProp.StatusDescription = ("You have not specified session header");
                        responseProp.Headers[HttpResponseHeader.ContentType] = "text/html";
                        reply.Properties[HttpResponseMessageProperty.Name]   = responseProp;
                        requestContext.Reply(reply);
                        // set the request context to null to terminate processing of this request
                        requestContext = null;
                    }
                    else
                    {
                        string session = requestProp.Headers[SessionHeader];
                        int    userCode;
                        if (!IsSessionValid(session, out userCode))                        //if session is valid
                        {
                            responseProp.StatusCode        = HttpStatusCode.Unauthorized;
                            responseProp.StatusDescription = ("session is not exist or out of date");
                            responseProp.Headers[HttpResponseHeader.ContentType] = "text/html";
                            reply.Properties[HttpResponseMessageProperty.Name]   = responseProp;
                            requestContext.Reply(reply);
                            // set the request context to null to terminate processing of this request
                            requestContext = null;
                        }
                        else
                        {
                            requestProp.Headers.Add("xUserCode", "userCode");
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Applies the HTTP response settings.
        /// </summary>
        /// <param name="fault">The fault.</param>
        /// <param name="statusCode">The status code.</param>
        /// <param name="statusDescription">The status description.</param>
        /// Get the HttpResponseMessageProperty
        protected virtual void ApplyHttpResponseSettings(
            ref Message fault, System.Net.HttpStatusCode statusCode,
            string statusDescription)
        {
            var httpResponse = new HttpResponseMessageProperty()
            {
                StatusCode        = statusCode,
                StatusDescription = statusDescription
            };

            httpResponse.Headers.Add(HttpResponseHeader.ContentType, "application/json");
            fault.Properties.Add(HttpResponseMessageProperty.Name, httpResponse);
        }
示例#18
0
        public void BeforeSendReply(ref Message reply, object correlationState)
        {
            var context = OperationContext.Current.Extensions.Find <ConnectionContext>();

            OperationContext.Current.Extensions.Remove(context);

            if (reply.IsFault)
            {
                var property = new HttpResponseMessageProperty();
                property.StatusCode = System.Net.HttpStatusCode.OK;
                reply.Properties[HttpResponseMessageProperty.Name] = property;
            }
        }
示例#19
0
        protected virtual void InternalReply(Message msg, TimeSpan timeout)
        {
            if (msg == null)
            {
                throw new ArgumentNullException("msg");
            }

            //Logger.LogMessage (MessageLogSourceKind.TransportSend, ref msg, Channel.Source.Source.MaxReceivedMessageSize);

            MemoryStream ms = new MemoryStream();

            Channel.Encoder.WriteMessage(msg, ms);
            Context.Response.ContentType = Channel.Encoder.ContentType;

            string pname = HttpResponseMessageProperty.Name;
            bool   suppressEntityBody = false;

            if (msg.Properties.ContainsKey(pname))
            {
                HttpResponseMessageProperty hp = (HttpResponseMessageProperty)msg.Properties [pname];
                string contentType             = hp.Headers ["Content-Type"];
                if (contentType != null)
                {
                    Context.Response.ContentType = contentType;
                }
                Context.Response.Headers.Add(hp.Headers);
                if (hp.StatusCode != default(HttpStatusCode))
                {
                    Context.Response.StatusCode = (int)hp.StatusCode;
                }
                Context.Response.StatusDescription = hp.StatusDescription;
                if (hp.SuppressEntityBody)
                {
                    suppressEntityBody = true;
                }
            }
            if (msg.IsFault)
            {
                Context.Response.StatusCode = 500;
            }
            if (!suppressEntityBody && ms.Length > 0)
            {
                Context.Response.SetLength(ms.Length);
                Context.Response.OutputStream.Write(ms.GetBuffer(), 0, (int)ms.Length);
                Context.Response.OutputStream.Flush();
            }
            else
            {
                Context.Response.SuppressContent = true;
            }
        }
            public void BeforeSendReply(ref Message reply, object correlationState)
            {
                if (reply != null && reply.IsFault)
                {
                    var property = new HttpResponseMessageProperty {
                        StatusCode        = System.Net.HttpStatusCode.OK,
                        StatusDescription = reply.ToString()
                    };

                    // Here the response code is changed to 200.

                    reply.Properties[HttpResponseMessageProperty.Name] = property;
                }
            }
示例#21
0
        public Message SerializeReply(MessageVersion messageVersion, object[] parameters, object result)
        {
            byte[]  body         = JsonHelper.GetReturnJsonBody(result);
            Message replyMessage = Message.CreateMessage(messageVersion, _operation.Messages[1].Action,
                                                         new RawBodyWriter(body));

            replyMessage.Properties.Add(WebBodyFormatMessageProperty.Name,
                                        new WebBodyFormatMessageProperty(WebContentFormat.Raw));
            var respProp = new HttpResponseMessageProperty();

            respProp.Headers[HttpResponseHeader.ContentType] = "application/json;charset=utf-8";
            replyMessage.Properties.Add(HttpResponseMessageProperty.Name, respProp);
            return(replyMessage);
        }
        public void AfterReceiveReply(ref Message reply,
                                      object correlationState)
        {
            object obj;

            if (reply.Properties.TryGetValue(HttpResponseMessageProperty.Name, out obj))
            {
                HttpResponseMessageProperty httpResponseMsg = obj as HttpResponseMessageProperty;
                if (!string.IsNullOrEmpty(httpResponseMsg.Headers["Set-Cookie"]))
                {
                    cookieCont.SetCookies((Uri)correlationState, httpResponseMsg.Headers["Set-Cookie"]);
                }
            }
        }
示例#23
0
        private void ConfigureResponseMessage(Message message)
        {
            Contract.Assert(message != null);

            HttpResponseMessageProperty responseProperty    = new HttpResponseMessageProperty();
            HttpResponseMessage         httpResponseMessage = message.ToHttpResponseMessage();

            if (httpResponseMessage == null)
            {
                responseProperty.StatusCode         = HttpStatusCode.InternalServerError;
                responseProperty.SuppressEntityBody = true;
            }
            else
            {
                responseProperty.StatusCode = httpResponseMessage.StatusCode;
                if (
                    httpResponseMessage.ReasonPhrase != null &&
                    httpResponseMessage.ReasonPhrase != DefaultReasonPhrase
                    )
                {
                    responseProperty.StatusDescription = httpResponseMessage.ReasonPhrase;
                }

                CopyHeadersToNameValueCollection(
                    httpResponseMessage.Headers,
                    responseProperty.Headers
                    );
                HttpContent content = httpResponseMessage.Content;
                if (content != null)
                {
                    CopyHeadersToNameValueCollection(
                        httpResponseMessage.Content.Headers,
                        responseProperty.Headers
                        );
                }
                else
                {
                    responseProperty.SuppressEntityBody = true;
                }
            }

            message.Properties.Clear();
            message.Headers.Clear();

            message.Properties.Add(HttpResponseMessageProperty.Name, responseProperty);

            // The current request context flows with the Message for later use
            // by HttpMessageEncoder.WriteMessage
            message.Properties.Add(HttpMessageEncodingRequestContextPropertyName, this);
        }
示例#24
0
        private static Message ConfigureResponseMessage(Message message)
        {
            if (message == null)
            {
                return(null);
            }

            HttpResponseMessageProperty responseProperty = new HttpResponseMessageProperty();

            HttpResponseMessage httpResponseMessage = message.ToHttpResponseMessage();

            if (httpResponseMessage == null)
            {
                responseProperty.StatusCode         = HttpStatusCode.InternalServerError;
                responseProperty.SuppressEntityBody = true;
            }
            else
            {
                responseProperty.StatusCode = httpResponseMessage.StatusCode;
                if (httpResponseMessage.ReasonPhrase != null &&
                    httpResponseMessage.ReasonPhrase != DefaultReasonPhrase)
                {
                    responseProperty.StatusDescription = httpResponseMessage.ReasonPhrase;
                }

                CopyHeadersToNameValueCollection(httpResponseMessage.Headers, responseProperty.Headers);
                HttpContent content = httpResponseMessage.Content;
                if (content != null)
                {
                    ObjectContent objectContent = content as ObjectContent;
                    if (objectContent != null)
                    {
                        objectContent.DetermineWriteSerializerAndContentType();
                    }

                    CopyHeadersToNameValueCollection(httpResponseMessage.Content.Headers, responseProperty.Headers);
                }
                else
                {
                    responseProperty.SuppressEntityBody = true;
                }
            }

            message.Properties.Clear();
            message.Headers.Clear();

            message.Properties.Add(HttpResponseMessageProperty.Name, responseProperty);

            return(message);
        }
示例#25
0
        Message GetCustomer(Message message)
        {
            Message response = null;

            HttpRequestMessageProperty  requestProperties  = message.Properties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty;
            HttpResponseMessageProperty responseProperties = new HttpResponseMessageProperty();

            Customer customer = null;

            Console.WriteLine("Received GET for " + message.Properties.Via);

            Uri    endpointUri = OperationContext.Current.EndpointDispatcher.EndpointAddress.Uri;
            string id          = CustomerIdFromRequestUri(message.Properties.Via, endpointUri);

            if (id != null)
            {
                customerList.TryGetValue(id, out customer);
            }
            else
            {
                //No customer was specified, so return the contents of the collection as links
                List <Uri> links = new List <Uri>();

                foreach (string customerId in this.customerList.Keys)
                {
                    links.Add(new Uri(message.Properties.Via + customerId));
                }

                responseProperties.StatusCode = HttpStatusCode.OK;
                response = Message.CreateMessage(message.Version, message.Headers.Action, links);
                response.Properties[HttpResponseMessageProperty.Name] = responseProperties;
                return(response);
            }

            if (customer == null)
            {
                responseProperties.StatusCode = HttpStatusCode.NotFound;
                response = Message.CreateMessage(message.Version, message.Headers.Action, String.Empty);
            }
            else
            {
                responseProperties.StatusCode = HttpStatusCode.OK;
                response = Message.CreateMessage(message.Version, message.Headers.Action, customer);
            }

            response.Properties[HttpResponseMessageProperty.Name] = responseProperties;

            return(response);
        }
示例#26
0
文件: WcfService.cs 项目: yrest/wcf
        public void ReturnContentType(string contentType)
        {
            var    outgoingMessageProperties = OperationContext.Current.OutgoingMessageProperties;
            object httpResponseMessagePropertyObj;

            if (!outgoingMessageProperties.TryGetValue(HttpResponseMessageProperty.Name, out httpResponseMessagePropertyObj))
            {
                httpResponseMessagePropertyObj = new HttpResponseMessageProperty();
                outgoingMessageProperties.Add(HttpResponseMessageProperty.Name, httpResponseMessagePropertyObj);
            }

            var httpRespononseMessageProperty = (HttpResponseMessageProperty)httpResponseMessagePropertyObj;

            httpRespononseMessageProperty.Headers[HttpResponseHeader.ContentType] = contentType;
        }
示例#27
0
        /// <summary>
        /// Inspects a message after a reply message is received but prior to passing it back to the client application.
        /// </summary>
        /// <param name="reply">The message to be transformed into types and handed back to the client application.</param>
        /// <param name="correlationState">Correlation state data.</param>
        public void AfterReceiveReply(ref Message reply, object correlationState)
        {
            HttpResponseMessageProperty httpResponse =
                reply.Properties[HttpResponseMessageProperty.Name] as HttpResponseMessageProperty;

            if (httpResponse != null)
            {
                string cookie = httpResponse.Headers[HttpResponseHeader.SetCookie];

                if (!string.IsNullOrEmpty(cookie))
                {
                    this.SharedCookie = cookie;
                }
            }
        }
示例#28
0
        public static Message CreateMessage(MessageVersion version, string action, string contentType, StreamWriterDelegate writer)
        {
            DelegateBodyWriter bodyWriter = new DelegateBodyWriter(writer);

            Message message = Message.CreateMessage(version, action, bodyWriter);

            message.Properties.Add(WebBodyFormatMessageProperty.Name, new WebBodyFormatMessageProperty(WebContentFormat.Raw));

            HttpResponseMessageProperty response = new HttpResponseMessageProperty();

            response.Headers[System.Net.HttpResponseHeader.ContentType] = contentType;
            message.Properties.Add(HttpResponseMessageProperty.Name, response);

            return(message);
        }
        void IDispatchMessageInspector.BeforeSendReply(ref System.ServiceModel.Channels.Message reply, object correlationState)
        {
            if (null == reply)
            {
                return;
            }

            if (reply.IsFault)
            {
                HttpResponseMessageProperty property = new HttpResponseMessageProperty();
                property.StatusCode = System.Net.HttpStatusCode.OK; // 200

                reply.Properties[HttpResponseMessageProperty.Name] = property;
            }
        }
示例#30
0
        /// <summary>
        /// Inspects a message after a reply message is received but prior to passing it back to the client application.
        /// </summary>
        /// <param name="reply">The message to be transformed into types and handed back to the client application.</param>
        /// <param name="correlationState">Correlation state data.</param>
        public void AfterReceiveReply(ref Message reply, object correlationState)
        {
            HttpResponseMessageProperty httpResponse =
                reply.Properties[HttpResponseMessageProperty.Name] as HttpResponseMessageProperty;

            if (httpResponse != null)
            {
                string cookie = httpResponse.Headers[HttpResponseHeader.SetCookie];

                if (!string.IsNullOrEmpty(cookie))
                {
                    cookieContainer.SetCookies(new System.Uri(Uri), cookie);
                }
            }
        }