我想确保在我们的WCF中返回数据集的所有操作都具有在Property SchemaSerializationMode中设置的.ExcludedSchema值。在WCF操作中修改返回值
我可以使用CustomBehavior执行此操作吗? 我试图实现一个CustomDispatchBehavior并添加一个MessageInspector,但AfterReceiveRequest和BeforeSendReply方法不会让我对返回值做任何事情。在BeforeSendreply中,返回值已经被序列化。我可以在哪里插入我的代码?
public class CustomDispatchBehavior : BehaviorExtensionElement, IServiceBehavior
{
public override Type BehaviorType
{
get { return typeof(CustomDispatchBehavior); }
}
protected override object CreateBehavior()
{
return new CustomDispatchBehavior();
}
void IServiceBehavior.AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, System.Collections.ObjectModel.Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters)
{
//throw new NotImplementedException();
}
void IServiceBehavior.ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
//throw new NotImplementedException();
foreach (ChannelDispatcher chanDisp in serviceHostBase.ChannelDispatchers)
{
foreach (EndpointDispatcher ed in chanDisp.Endpoints)
{
ed.DispatchRuntime.MessageInspectors.Add(new MyMessageInspector());
}
}
}
void IServiceBehavior.Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
//throw new NotImplementedException();
}
}