Q Как я могу получить исходное исключение (возникшее на сервере) на стороне клиента?
Я работаю со службой WCF с собственным размещением и C # 4 и пытаюсьнастроить правильную обработку исключений.
У меня есть клиент, который выглядит следующим образом
private ServiceResponse PerformRemoteAction(ServiceRequest request, ProcessOperations operation)
{
...
try
{
//remote call
switch (operation)
{
...
case ProcessOperations.VerifyAction: { response = client.VerifyAction(request); break; }
default: throw new NotImplementedException();
}
}
catch (Exception ex)
{
AppManager.LogException(ex);
}
return response;
}
И реализация службы
public override ServiceResponse VerifyAction(ServiceRequest request)
{
RegisterRequest(request);
try
{
var chain = new VerificationChain();
Responce = chain.Run(request);
}
catch (Exception ex)
{
throw new FaultException<WcfException>(ExceptionFactory.Create(ex),
new FaultReason(ex.Message));
}
SetSuccessfulResponce();
return Responce;
}
Служба web.config имеет
<behaviors>
<serviceBehaviors>
<behavior>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
Это мое первоначальное исключение
И это то, что я получаю на клиенте
При необходимости я могу опубликовать полную информацию на стороне клиента, однакоисключение на клиенте не имеет ссылки на исходное.
Обновление Это мой интерфейс с определенным FaultContractAttribute
[ServiceContract]
public interface IServiceOperation : IOperation
{
...
[OperationContract(Action = "http://tempuri.org/ITestRunnerService/VerifyAction", ReplyAction = "http://tempuri.org/ITestRunnerService/VerifyAction")]
[FaultContractAttribute(typeof(WcfException), Action = "http://tempuri.org/ITestRunnerService/ExecuteRequestWcfExceptionFault", Name = "WcfException", Namespace = "http://schemas.datacontract.org/2004/07/TH.Core.Exceptions")]
ServiceResponse VerifyAction(ServiceRequest request);
}
А это мой WcfException класс
[DataContract]
public class WcfException : Exception
{
[DataMember]
public string Title { get; set; }
[DataMember]
public new string Message { get; set; }
[DataMember]
public new string InnerException { get; set; }
[DataMember]
public new string StackTrace { get; set; }
}