I have a WCF client test harness where I'm using a "client message inspector" endpoint behavior to "pick off" raw requests and response messages going to and from a service and save them for later display in the UI.
This works great, except for the use case where invalid credentials are passed (Basic Authentication). The server returns an HTTP 401 along with a SOAP fault in the body containing details of what happened. I have no control over the service, so this behavior cannot be changed.
Because the HTTP 401 is returned as a WebException
, my message inspector never fires and I can't get to the raw response. This exception eventually gets to the UI in the form a MessageSecurityException
.
Is there any way to suppress this so the message inspector's AfterReceiveReply
still fires? or is there somewhere else I can access the entire raw response?
Thanks!