Altering operation messages via MessageInspector
In this chapter, we have covered many WCF extension components that can intercept the service operation calls, including OperationInvoker
, ParameterInspectors
, and MessageFilter
. Each of them focuses on a certain point within the entire WCF operation execution process. This recipe will introduce another extension component, MessageInspector
, which can help intercept the entire SOAP message of each WCF operation call.
How to do it...
In our sample scenario, we have a WCF service that contains an operation that returns a list of ProductItem
objects (each of which contains a Name
and an Amount
property). The ServiceContract
and related data types are shown in the following code snippet:
[ServiceContract] public interface IDataService { [OperationContract] List<ProductItem> GetProductList(); } [DataContract(Namespace="")] public class ProductItem { [DataMember] public string Name { get; set; } [DataMember] public int Amount...