我在 IIS 中托管了多个 WCF 服务,我正在向这些服务应用相同的自定义服务行为。我正在寻找一种通过配置将多个参数传递给行为的方法,例如在行为扩展或行为元素中。
如果有帮助,我还将在 ApplyDispatchBehavior 中添加自定义消息检查器,因此我需要将参数传递给检查器:
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
foreach (ChannelDispatcher channelDispatcher in serviceHostBase.ChannelDispatchers)
{
foreach (EndpointDispatcher endpointDispatcher in channelDispatcher.Endpoints)
{
endpointDispatcher.DispatchRuntime.MessageInspectors.Add(
new ValidatingMessageInspector(<custom parameters>));
}
}
}