Marty
Marty

Reputation: 1202

Disable WebFaultClientMessageInspector in WCF Client?

I'm using WCF to invoke a remote REST API, and am getting a 500 Internal Server Error from the service. Using Fiddler, I can see the body of the 500 response (which includes, buried in HTML, the reason for the 500 error). I would like to be able to examine the response body in .Net, but it appears that the WebFaultClientMessageInspector gets there first, and throws a vague exception.

enter image description here

Is there anyway to disable/override this inspector (and see the full response body)?

Upvotes: 0

Views: 239

Answers (2)

Marty
Marty

Reputation: 1202

I think I've figured this out - I do need a custom message inspector (IClientMessageInspector), but I also need to configure it FIRST in my WCF Endpoint configuration:

<endpointBehaviors>
  <behavior name="myCustomErrorWebHttp">
    <myCustomnClientBehavior />
    <webHttp />
  </behavior>
</endpointBehaviors>

Doing THIS caused my inspector to be triggered BEFORE WebFaultClientMessageInspector, and I was able to inspect the message body.

Upvotes: 1

The scion
The scion

Reputation: 972

From this link

How to solve this problem? The answer is obvious: create custom implementation IClientMessageInspector and use it on client.

Full details is in the link.

Upvotes: 0

Related Questions