HttpMessageInspector

Topics: Web Api
Oct 15, 2011 at 11:59 PM

Hi Guys,

I want to intercept all the outbound message and apply some data restriction. So how can add this to WebApiconfiguration object?

-Henry

Oct 16, 2011 at 12:25 AM

Hi,

You can use couple of options for this purpose.

1. You can use operation handlers called ResponseHandlers which get executed after the service operation returns. On the WebApiConfiguration object, there should be a property called ResponseHandlers to do the hook up.

2. You can access the outbound response even in MessageHandler pipeline. For this you need to hookup message handlers using the configuration object. You can do this via MessageHandlers property or if you want to provide a factory, you can do so using the MessageHandlerFactory property on it.

Btw, currently i would suggest you to use Option 1. as we seem to have a bug in getting the content returned by a service operation using Option 2. However, this bug as been fixed in our soure code and will be part of our next update.

if you are new to these concepts, you can go through this great blog: http://pfelix.wordpress.com/

Thanks, Kiran Challa

Coordinator
Oct 16, 2011 at 3:41 AM
You can add response operation handlers for each of your operations. Or you can add a message handler that examines all HTTP response messages.

Sent from my Windows Phone

From: HenryBhavsar
Sent: 10/15/2011 3:59 PM
To: Daniel Roth
Subject: HttpMessageInspector [wcf:276026]

From: HenryBhavsar

Hi Guys,

I want to intercept all the outbound message and apply some data restriction. So how can add this to WebApiconfiguration object?

-Henry