过滤webservice的请求日志,做权限验证功能等。
1.
namespace WebApplication1 { public class SimpleWSInvokeMonitorExtension : SoapExtension { Stopwatch stopWatch = null; string startLoginfo = ""; public override Stream ChainStream(Stream stream) { return stream; } public override object GetInitializer(Type serviceType) { //throw new NotImplementedException(); return null; } public override object GetInitializer(LogicalMethodInfo methodInfo, SoapExtensionAttribute attribute) { //throw new NotImplementedException(); return null; } public override void Initialize(object initializer) { //throw new NotImplementedException(); } public override void ProcessMessage(SoapMessage message) { switch (message.Stage) { case SoapMessageStage.BeforeSerialize: break; case SoapMessageStage.AfterSerialize: stopWatch.Stop(); var sec = stopWatch.ElapsedMilliseconds; string endLogInfo = string.Format("{0},总花费时间{1}ms,请求ip{2}", startLoginfo, stopWatch.ElapsedMilliseconds.ToString(), GetClientIp()); break; case SoapMessageStage.BeforeDeserialize: break; //about to call method; case SoapMessageStage.AfterDeserialize: CertficateSoap(message);