私たちのアプリケーションでは、すべてのデータ コントラクトに 1 つの親がOperationResponse
あり、これには呼び出し結果 ( Ok、InvalidParams、ErrorOperationResponse
) を表すenum (OperationState
プロパティの列挙型) が含まれます。Result
例外の後に WCF の動作を上書きするにはどうすればよいですか? Fault 状態を返すのではなく、従来のメッセージ、私の場合は OperationResponse を返しますが、プロパティ Result = OperationState.Error を使用しますか?
編集:私は正しいと思います.IErrorHandlerを実装する必要がありますが、エラーメッセージを送信エラーメッセージに設定する方法がわからないため、今は迷っています...
public bool HandleError(Exception error)
{
// log error
return true; // we catch error and provide our custom message.
}
public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
{
// create result message
var message = new OperationResponse
{
Result = OperationState.Error
};
// ok how to return message into ref fault?
}
Edit2:解決策がなければ解決できない問題のようです...私はこのスレッドのような解決策のない同じ質問しか見つけませんでした... :(