asp.net中WebService 捕获全局异常
发布时间:2020-12-16 09:28:41 所属栏目:asp.Net 来源:网络整理
导读:在WebService?中,使用IHttpHand?捕获不到全局异常,这时候,需要使用?? SoapExtension 代码如下 ? public class SoapExceptionHandler : System.Web.Services.Protocols.SoapExtension { public override object GetInitializer(Type serviceType) { return
在WebService?中,使用IHttpHand?捕获不到全局异常,这时候,需要使用??SoapExtension 代码如下 ? 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); } } } } ? 同时,需要在web.config里面进行配置 找到<webServices>?节点 添加如下配置 <soapExtensionTypes> <add type="Eway.HR.WebService.SoapExceptionHandler,Eway.HR.WebService" priority="1" group="High" /> </soapExtensionTypes> 这时候,如果直接使用vs直接用网页打开进行调试,是不会有效果的,因为这种方式不是一个完整的soap, 可以使用?WebserviceStudio?进行测试,下载地址:https://archive.codeplex.com/?p=WebserviceStudio ? WebserviceStudio(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – WCF:是否有一个属性要在OperationContract中生
- ASP.NET SessionID类型
- asp.net-mvc – 如何将POST请求重定向到维护MVC中的模型值的
- asp.net核心 – ASP.NET vNext – 编译代码动态不适合我
- asp.net webservice返回json的方法
- 在ASP.Net中,在哪个页面生命周期事件中,viewstate被加载?
- asp.net-mvc – 每个请求DbContext发生随机错误
- asp.net-mvc-3 – mvc3 https&http
- asp.net-core – .net核心和SAML 2.0
- 是否可以在IIS中禁用ASP.NET网站睡眠?
推荐文章
站长推荐
热点阅读