Reputation: 6636
I have a WCF service. I would like to include some XML comments in the message returned by the service. (to help developers debug situations, where the defined contract does not expose enough information to be helpful) The comments will vary per execution.
I cannot change the contract as it is provided by my client.
I am aware of message inspectors, and the ability to decorate the contract methods, and therefore manipulate the response directly, but I don't see how I could pass the per-execution custom information to the inspector to add it into the response.
Upvotes: 1
Views: 127
Reputation: 5801
how I could pass the per-execution custom information to the inspector
You do this by extending the InstanceContext. See my answer to How to find out whether current method is flagged with IsOneWay for an example of using a custom context to pass information from an IOperationInvoker to the service. Start with the line of code that says:
OneWayContext.Current.IsOneWay = this.isOneWay;
You can change the code in that answer to pass information from the service to an inspector.
The best general reference on the topic is Carlos Figueira's blog: IExtension and IExtensibleObject
Upvotes: 1