I have a WCF based test harness client for a set of web services. The test client allows me to see raw requests and responses going to and from the services. A Message Inspector endpoint behavior is used to "pick off" the raw requests and response messages and save them for later display in the UI.
This works great, except for the use case where invalid credentials are passed. The server returns an HTTP 401 along with a SOAP fault containing details of what happened. This hurts me in a couple ways:
- On the client this shows up as a
MessageSecurityException
not aFaultException
, so I can't get the details from the fault. - This exception appears to prevent the
AfterReceiveReply
event handler on my message inspector from firing, so I have no access to the raw response.
Is there any way I can handle this case so that the SOAP fault comes through as a FaultException and allow my message inspector to handle responses regardless of the HTTP status code that is returned?
Thanks!