Friday, February 18, 2011

WCF REST Internal Microsoft HttpWebResponse validation rules

The posting WCF REST Exception handling deals with handling ProtocolExceptions thrown by Microsoft's WCF REST implementation. This specific ProtocolException/Exception is thrown based on rules located in various methods in the following classes/methods in the .NET framework.

private bool CompleteGetResponse(IAsyncResult result);
 
Declaring Type: System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest 
Assembly: System.ServiceModel, Version=4.0.0.0 

 
public Message WaitForReply(TimeSpan timeout);
 
Declaring Type: System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest 
Assembly: System.ServiceModel, Version=4.0.0.0 
Then you can trace the code into the various static utility methods such as

Declaring Type: System.ServiceModel.Channels.HttpChannelUtilities 
Assembly: System.ServiceModel, Version=4.0.0.0 


public static HttpWebResponse ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason);
 
public static HttpInput ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding);

public static Exception CreateNullReferenceResponseException(NullReferenceException nullReferenceException);

2 comments:

Anonymous said...

What value is this post supposed to provide??? There is nothing insightful here....

Kenneth Thorman said...

As mentioned in WCF REST Exception handling I was trying to figure out how to hook into the WCF framework to be able to catch the response before the framework threw the ProtocolException. This post was marked as "NoteToSelf" since it primarily was made to myself to remember how far my investigations had taken me.