I am trying to port some of the channel interceptors (REST Starter kit) to the current WCF Http bits, but it looks like the current channel implementation changed considerably.
This line of code used to work with the previous WCF Http Channel,
HttpRequestMessageProperty request = (HttpRequestMessageProperty)requestMessage.Properties[HttpRequestMessageProperty.Name];
requestMessage in the code above is an instance of the Message class received in the channel or interceptor. It looks like the channel implementation in the new bits is creating a new message and not setting the properties correctly so there is no way to
get the Http Request from the message. The only workaround I found so far is to use reflection against a public method in the new HttpMessage class (which is internal),
Message requestMessage = requestContext.RequestMessage;
HttpRequestMessage request = (HttpRequestMessage)(requestMessage.GetType().InvokeMember("GetHttpRequestMessage",
BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod,
null, requestMessage, null));
Not sure what the plans for a new channel model are, but it would be nice to have support at least for the existing WCF http channels or interceptors.