我已经实现了IdispatchMessageInspector的成员来验证来自 SOAP 标头的 tokenId。如果令牌无效,我想重定向错误消息。这样它就会限制访问网络方法。我不知道该怎么做?以前有人做过吗?
#region IDispatchMessageInspector 成员
public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, IClientChannel channel, InstanceContext instanceContext)
{
if !(ValidateToken(tokenValue))
//Redirect the error message
return null;
}
public void BeforeSendReply(ref System.ServiceModel.Channels.Message reply, object correlationState)
{
//Log the Response with Log4Net or
Console.WriteLine("IDispatchMessageInspector.BeforeSendReply called.");
}
#endregion