我有一个SoapExtension
,目前只写一个日志:
public class CatchInputParametersExtension : SoapExtension
{
public override object GetInitializer(Type serviceType)
{
return null;
}
public override object GetInitializer(LogicalMethodInfo methodInfo, SoapExtensionAttribute attribute)
{
return null;
}
public override void Initialize(object initializer)
{
//nothing to do
}
public override void ProcessMessage(SoapMessage message)
{
Logger.Log("++++++++ Before Everything +++++++ " + message.ToString(), LogLevel.Info);
switch (message.Stage)
{
case SoapMessageStage.BeforeSerialize:
Logger.Log("++++++++ Before Serialize +++++++ " + message.ToString(), LogLevel.Info);
break;
case SoapMessageStage.AfterSerialize:
Logger.Log("++++++++ After Serialize +++++++ " + message.ToString(), LogLevel.Info);
break;
case SoapMessageStage.BeforeDeserialize:
Logger.Log("++++++++ Before Deserialize +++++++ " + message.ToString(), LogLevel.Info);
break;
case SoapMessageStage.AfterDeserialize:
Logger.Log("++++++++ After Deserialize +++++++ " + message.ToString(), LogLevel.Info);
break;
default:
throw new Exception("invalid stage");
}
}
}
我尝试用两个web.config
文件注册它
<webServices>
<soapExtensionTypes>
<add type="WebAdminServices.SoapExtensions.CatchInputParametersExtension,WebAdminServices" priority="1" group="Low"/>
</soapExtensionTypes>
</webServices>
和SoapExtensionAttribute
[AttributeUsage(AttributeTargets.Method)]
public class CatchInputParametersAttribute : SoapExtensionAttribute
{
private int priority;
public override Type ExtensionType
{
get { return typeof(CatchInputParametersExtension); }
}
public override int Priority
{
get { return priority; }
set { priority = value; }
}
}
这是由注册的
[WebMethod(Description = "Test1")]
[CatchInputParametersAttribute(Priority=1)]
public string Test1(int a, int b, int c)
{
// do stuff
return stuff;
}
但它们似乎都不起作用,日志文件从不显示这些++++++
行。请问有什么提示吗?