WCF AfterReceiveRequest(IDispatchMessageInspector的成员)找出请求类型?

时间:2015-07-13 11:56:21

标签: c# wcf

在AfterReceiveRequest方法中是否有任何方法可以找到requst类型(httprequest或Soap reqest)?

public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)
{
    //get request type
}

1 个答案:

答案 0 :(得分:0)

我自己没有这样做,但由于没有人给出答案,我建议尝试这样做: 而不是(或除了)实现IDispatchMessageInspector,实现IServiceBehavior并检查Validate方法中的URI方案:

public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
    foreach (ServiceEndpoint item in serviceDescription.Endpoints)
    {
        string theScheme = item.Binding.Scheme;
    }
}