我面對的是一個設計/建築問題,並不能找出一個乾淨的解決方案。我們有一個帶有數百個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