我面对的是一个设计/建筑问题,并不能找出一个干净的解决方案。我们有一个带有数百个WebMethods的.NET WebService。 (见下面的例子)。如果有任何所谓的WebMethods的抛出未处理的异常,我们要生成的电子邮件。.NET WebService的错误处理设计
问题:在这种情况下使用干净的设计模式是什么。我想避免将重复代码到几百方法呢?
[WebService(Namespace = "http://example.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[Serializable]
public class WebService : System.Web.Services.WebService
{
[WebMethod]
public string GetQuoteInfo(string request)
{
return QuoteService.GetQuoteInfo(request);
}
[WebMethod]
public string GetQuoteAPR(string request)
{
return QuoteService.GetQuoteAPR(request);
}
[WebMethod]
public string GetAccountContactInfo(string request)
{
return AccountService.GetAccountContactInfo(request);
}
...
...
...
[WebMethod]
public string GetAccountContactInfo(string request)
{
// implementation
}
}
可能相关的博客文章:应对全球Web服务未处理的异常(https://blogs.msdn.microsoft.com/nikhilsi/2008/06/11/handling-global-web-service-unhandled-exceptions/) 。 – Romoku