In WebService using IHttpHand not capture global exception, this time, it is necessary to use SoapExtension
code show as below
public class SoapExceptionHandler : System.Web.Services.Protocols.SoapExtension { public override object GetInitializer(Type serviceType) { return null; } public override object GetInitializer(System.Web.Services.Protocols.LogicalMethodInfo methodInfo, System.Web.Services.Protocols.SoapExtensionAttribute attribute) { return null; } public override void Initialize(object initializer) { } public override void ProcessMessage(System.Web.Services.Protocols.SoapMessage message) { if (message.Stage == SoapMessageStage.AfterSerialize) { if (message.Exception != null) { AppLog.Info(message.Exception.InnerException); //LogUtil.Log.Error(message.Exception.InnerException); } } } }
At the same time, there needs to be configured in web.config
Find <webServices> node
Add the following configuration
<soapExtensionTypes> <add type="Eway.HR.WebService.SoapExceptionHandler, Eway.HR.WebService" priority="1" group="High" /> </soapExtensionTypes>
At this time, if used directly with a web vs open debugging directly, there will be no effect, because in this way is not a complete soap,
You can use WebserviceStudio test Download: https://archive.codeplex.com/?p=WebserviceStudio