Azad
Azad

Reputation: 39

wcf idispatchmessageinspector BeforeSendReply not called

I've implemented idispatchmessageinspector in my service. I did not want to do this as an attribute. I want the BeforeSendReply to add additional data into the header. the problem I have is that it is not being called and the header is returned null. essentially, I am treating this as event driven to have this called every time the method completes execution.

could someone explain the execution of the BeforeSendReply?

hope it makes sense.

A sample of what I want to accomplish have below:

class test
implements itest
implements idispatchmessageinspector 

public function testFunction as string implements itest.testFunction 
begin
return somestring
end

sub BeforeSendReply (reply ...) implement ..
begin

dim header = ...

reply.headers.add(header)

end

Upvotes: 3

Views: 1811

Answers (1)

carlosfigueira
carlosfigueira

Reputation: 87293

Making a class implement the IDispatchMessageInspector interface doesn't make it be added to the WCF pipeline. You need to use a behavior to insert an instance of the inspector in the endpoint dispatch runtime. You can find more detailed information at http://blogs.msdn.com/b/carlosfigueira/archive/2011/04/19/wcf-extensibility-message-inspectors.aspx.

Upvotes: 4

Related Questions