2010-04-09 46 views
0

我們有以下WCF服務合同:WCF故障沒有被傳播到客戶端正確

[ServiceContract(Namespace = "http://example.com", Name = "Service1")] 
public interface IService1 
{  
    [OperationContract] 
    [FaultContract(typeof(Fault1))] 
    ValidateUserResult ValidateUser(
         string username, 
         string password); 
} 

[ServiceContract(Namespace = "http://example.com", Name = "Service1")] 
public interface IService1Async 
{  
    [OperationContract(AsyncPattern = true)] 
    [FaultContract(typeof(Fault1))] 
    IAsyncResult BeginValidateUser(
         string username, 
         string password, 
         AsyncCallback callback, 
         object userState); 

    ValidateUserResult EndValidateUser(IAsyncResult asyncResult); 
} 

[DataContract(Namespace = "http://example.com")] 
public class Fault1 
{ 
} 

我們呼籲在客戶端的ValidateUser的異步版本,我們在服務器上拋出一個FaultException<Fault1> ,但所有客戶收到的是基地FaultException

什麼是沒有收到合同規定的錯誤的原因?

回答

1

我們現在發現爲什麼。我們使用ProvideFault方法從服務行爲中生成錯誤。在那裏我們使用類似於IErrorHandler.ProvideFault in msdn

這個例子的代碼,唯一的區別是我們沒有通過Message.CreateMessage重載的正確操作。我們完全複製了在手動拋出錯誤和瞧瞧的情況下生成的內容。

我沒有給出最後細節的藉口:-)

0

您能向我們展示您的通話語句嗎?合同和一切看起來都很好...

你以哪種順序檢查故障?你必須檢查FaultException<Fault1>之前檢查FaultExceptionCommunicationException - 你可能有任何機會,你可能有訂單混淆?

當您調用該方法的同步版本時它工作嗎?

相關問題