WCF AfterReceiveRequest get headers

前端 未结 1 715
傲寒
傲寒 2021-01-12 15:56

I just got started intercepting requests to my WCF service.

I\'m calling the web service with java code that looks like this ( short version )

connec         


        
相关标签:
1条回答
  • 2021-01-12 16:35

    The Headers property in the Message class will give you the SOAP headers; what you're looking for are the HTTP headers. To get to those, you should use the HttpRequestMessageProperty:

        public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
        {
            var prop = (HttpRequestMessageProperty)request.Properties[HttpRequestMessageProperty.Name];
            var userName = prop.Headers["Username"];
    
            return null;
        }
    
    0 讨论(0)
提交回复
热议问题