I am consuming a WCF service which has multiple operations, this service requires me to add outgoing message properties whenever I call any of its operations.
At the moment i am just adding the properties every time i call the service inside the code.
Here is my code to do it:
using (new OperationContextScope(client.InnerChannel))
{
OperationContext.Current.OutgoingMessageProperties.Add("P1", "Test User");
OperationContext.Current.OutgoingMessageProperties.Add("P2", "Test Type");
response = client.process(request);
}
How can I create a WCF extension that adds these message properties dynamically?
I have few knowledge about the extension but not enough to intercept and add these headers.
To add some headers to a message automatically you have to implement IClientMessageInspector. It will allow you to change anything for an outgoing message.
EDIT 2:
And you config file should look like this: