1

我使用IIS上託管的WCF服務。
還有,我用錯合同將錯誤發送給客戶端(的FaultException <「T>
在客戶端,我趕上的FaultException <」 T>顯示一些錯誤的用戶。
如果在服務器上拋出一些未處理的異常,WCF會生成純文本FaultException, ,以便客戶端捕獲它並顯示用戶「內部服務器錯誤」消息。爲什麼Enterprise Library不會在WCF中拋出FaultException

然後我開始使用企業庫5.0 for WCF異常屏蔽,並遇到以下問題。使用FaultContractExceptionHandler可能會將所有錯誤傳送到客戶端,但是在未處理的異常情況下客戶端收到CommunicationException而不是FaultException。其他一切正常工作。

如果我關閉了異常處理策略(刪除ExceptionShielding attibute),則客戶端按預期獲得FaultExceptions
你知道可能是什麼原因嗎?
謝謝。

PS:這裏是內部異常的鏈:
的CommunicationException - >引發WebException - > IOException的 - > SocketException
消息是「基礎連接已關閉:這是期望被保持活的連接被關閉服務器。」

的Web.config

<add name="ServiceException Policy"> 
    <exceptionTypes> 
     <add name="ServiceLogicException" type="LopService.Contracts.ServiceLogicException, LopService.Contracts, Version=1.0.0.1725, Culture=neutral, PublicKeyToken=null" 
     postHandlingAction="ThrowNewException"> 
     <exceptionHandlers> 
      <add type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
      faultContractType="LopService.Contracts.ServiceLogicFaultContract, LopService.Contracts, Version=1.0.0.1725, Culture=neutral, PublicKeyToken=null" 
      name="Fault Contract Exception Handler" /> 
     </exceptionHandlers> 
     </add> 
    </exceptionTypes> 
    </add> 

服務類

[ExceptionShielding("ServiceException Policy")] 
public partial class LopSoapService 
{... 

經營合同

[OperationContract] 
    [FaultContract(typeof(DataValidationFaultContract))] 
    [FaultContract(typeof(ServiceLogicFaultContract))] 
    int CreateUser(UserDto userDto, IEnumerable<ClaimRecordDto> claimRecords); 

回答

0

這似乎成爲企業圖書館的一個問題。請參閱workitem

相關問題