示例#1
0
文件: WcfService.cs 项目: yxbdali/wcf
        public TestHttpRequestMessageProperty EchoHttpRequestMessageProperty()
        {
            object obj;
            MessageProperties properties = new MessageProperties(OperationContext.Current.IncomingMessageProperties);
            if (properties.TryGetValue(HttpRequestMessageProperty.Name, out obj))
            {
                HttpRequestMessageProperty property = (HttpRequestMessageProperty)obj;
                if (property != null)
                {
                    TestHttpRequestMessageProperty testProperty = new TestHttpRequestMessageProperty();
                    testProperty.SuppressEntityBody = property.SuppressEntityBody;
                    testProperty.Method = property.Method;
                    testProperty.QueryString = property.QueryString;

                    WebHeaderCollection collection = property.Headers;
                    foreach (string s in collection.AllKeys)
                    {
                        string[] values = collection.GetValues(s);
                        testProperty.Headers.Add(s, String.Join(",", values));
                    }
                    return testProperty;
                }
            }

            return null;
        }