FaultException 클래스

정의

SOAP 오류를 나타냅니다.

public ref class FaultException : System::ServiceModel::CommunicationException
public class FaultException : System.ServiceModel.CommunicationException
[System.Serializable]
public class FaultException : System.ServiceModel.CommunicationException
[System.Serializable]
[System.Runtime.Serialization.KnownType(typeof(System.ServiceModel.FaultException+FaultCodeData[]))]
[System.Runtime.Serialization.KnownType(typeof(System.ServiceModel.FaultException+FaultReasonData[]))]
[System.Runtime.Serialization.KnownType(typeof(System.ServiceModel.FaultException+FaultCodeData))]
[System.Runtime.Serialization.KnownType(typeof(System.ServiceModel.FaultException+FaultReasonData))]
public class FaultException : System.ServiceModel.CommunicationException
type FaultException = class
    inherit CommunicationException
[<System.Serializable>]
type FaultException = class
    inherit CommunicationException
[<System.Serializable>]
[<System.Runtime.Serialization.KnownType(typeof(System.ServiceModel.FaultException+FaultCodeData[]))>]
[<System.Runtime.Serialization.KnownType(typeof(System.ServiceModel.FaultException+FaultReasonData[]))>]
[<System.Runtime.Serialization.KnownType(typeof(System.ServiceModel.FaultException+FaultCodeData))>]
[<System.Runtime.Serialization.KnownType(typeof(System.ServiceModel.FaultException+FaultReasonData))>]
type FaultException = class
    inherit CommunicationException
Public Class FaultException
Inherits CommunicationException
상속
상속
파생
특성

예제

다음 코드 예제에서는 try/catch 블록을 사용하여 서비스에서 throw된 개체를 catch하고 처리하는 FaultException 방법을 보여 줍니다. 서비스 애플리케이션에 디버깅이 설정된 경우 자주 발생합니다.

using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
using Microsoft.WCF.Documentation;

public class Client
{
  public static void Main()
  {
    // Picks up configuration from the configuration file.
    SampleServiceClient wcfClient = new SampleServiceClient();
    try
    {
      // Making calls.
      Console.WriteLine("Enter the greeting to send: ");
      string greeting = Console.ReadLine();
      Console.WriteLine("The service responded: " + wcfClient.SampleMethod(greeting));
      Console.WriteLine("Press ENTER to exit:");
      Console.ReadLine();
    }
    catch (TimeoutException timeProblem)
    {
      Console.WriteLine("The service operation timed out. " + timeProblem.Message);
      wcfClient.Abort();
      Console.ReadLine();
    }
    // Catch the contractually specified SOAP fault raised here as an exception.
    catch (FaultException<GreetingFault> greetingFault)
    {
      Console.WriteLine(greetingFault.Detail.Message);
      Console.Read();
      wcfClient.Abort();
    }
    // Catch unrecognized faults. This handler receives exceptions thrown by WCF
    // services when ServiceDebugBehavior.IncludeExceptionDetailInFaults
    // is set to true.
    catch (FaultException faultEx)
    {
      Console.WriteLine("An unknown exception was received. "
        + faultEx.Message
        + faultEx.StackTrace
      );
      Console.Read();
      wcfClient.Abort();
    }
    // Standard communication fault handler.
    catch (CommunicationException commProblem)
    {
      Console.WriteLine("There was a communication problem. " + commProblem.Message + commProblem.StackTrace);
      Console.Read();
      wcfClient.Abort();
    }
  }
}

Imports System.ServiceModel
Imports System.ServiceModel.Channels
Imports Microsoft.WCF.Documentation

Public Class Client
  Public Shared Sub Main()
    ' Picks up configuration from the configuration file.
    Dim wcfClient As New SampleServiceClient()
    Try
      ' Making calls.
      Console.WriteLine("Enter the greeting to send: ")
      Dim greeting As String = Console.ReadLine()
      Console.WriteLine("The service responded: " & wcfClient.SampleMethod(greeting))
      Console.WriteLine("Press ENTER to exit:")
      Console.ReadLine()
    Catch timeProblem As TimeoutException
      Console.WriteLine("The service operation timed out. " & timeProblem.Message)
      wcfClient.Abort()
      Console.ReadLine()
    ' Catch the contractually specified SOAP fault raised here as an exception.
    Catch greetingFault As FaultException(Of GreetingFault)
      Console.WriteLine(greetingFault.Detail.Message)
      Console.Read()
      wcfClient.Abort()
    ' Catch unrecognized faults. This handler receives exceptions thrown by WCF
    ' services when ServiceDebugBehavior.IncludeExceptionDetailInFaults 
    ' is set to true.
    Catch faultEx As FaultException
      Console.WriteLine("An unknown exception was received. " & faultEx.Message + faultEx.StackTrace)
      Console.Read()
      wcfClient.Abort()
    ' Standard communication fault handler.
    Catch commProblem As CommunicationException
      Console.WriteLine("There was a communication problem. " & commProblem.Message + commProblem.StackTrace)
      Console.Read()
      wcfClient.Abort()
    End Try
  End Sub
End Class

설명

서비스에서 클래스를 FaultException 사용하여 디버깅을 위해 클라이언트로 반환하는 형식화되지 않은 오류를 만듭니다.

클라이언트에서 알 수 없거나 제네릭 오류를 처리하는 개체(예: 속성이 로 설정된 서비스에서 반환되는 오류)IncludeExceptionDetailInFaults를 catch FaultException 합니다true. FaultException 확장되므로 개체를 CommunicationException개별적으로 잡으려면 개체를 잡기 CommunicationException 전에 개체 FaultException 를 catch해야 합니다.

참고

이중 서비스는 이중 클라이언트와의 상호 작용에서 반환된 개체를 catch FaultException 할 수도 있습니다.

일반적으로 클라이언트에 오류 정보가 필요하다고 결정한 모든 오류 사례에 대해 강력한 형식의 SOAP 오류(관리되지 않는 예외 개체가 아님)를 반환하도록 서비스를 디자인하는 것이 좋습니다 FaultContractAttribute . 그러나 다음과 같은 경우에 사용합니다 FaultException .

  • 디버깅을 위해 서비스에서 SOAP 오류를 보내려면

  • 오류가 서비스 계약의 일부가 아닌 경우 클라이언트에서 SOAP 오류를 catch합니다.

문자열을 생성자에 전달하고 메서드를 호출하여 클라이언트에서 검색하려는 경우 개체를 FaultException<TDetail>.ToString throw FaultException 합니다. 형식 매개 변수System.String가 있는 형식 System.ServiceModel.FaultException<TDetail> 의 오류 계약을 지정하면 문자열 값을 호출FaultException<TDetail>.ToString하지 않고 속성으로 FaultException<TDetail>.Detail 사용할 수 있습니다.

자세한 내용은 계약 및 서비스에서 오류 지정 및 처리를 참조하세요.

생성자

FaultException()

FaultException 클래스의 새 인스턴스를 초기화합니다.

FaultException(FaultReason)

지정된 원인을 사용하여 FaultException 클래스의 새 인스턴스를 초기화합니다.

FaultException(FaultReason, FaultCode)

지정된 원인과 오류 코드를 사용하여 FaultException 클래스의 새 인스턴스를 초기화합니다.

FaultException(FaultReason, FaultCode, String)

지정된 원인, 오류 코드 및 동작 값을 사용하여 FaultException 클래스의 새 인스턴스를 초기화합니다.

FaultException(MessageFault)

지정된 메시지 오류 값을 사용하여 FaultException 클래스의 새 인스턴스를 초기화합니다.

FaultException(MessageFault, String)

지정된 메시지 오류 값과 제공된 동작 문자열을 사용하여 FaultException 클래스의 새 인스턴스를 초기화합니다.

FaultException(SerializationInfo, StreamingContext)

스트림을 FaultException 개체로 역직렬화할 때 지정된 serialization 정보와 컨텍스트를 사용하여 FaultException 클래스의 새 인스턴스를 초기화합니다.

FaultException(String)

지정된 오류 원인을 사용하여 FaultException 클래스의 새 인스턴스를 초기화합니다.

FaultException(String, FaultCode)

지정된 원인과 SOAP 오류 코드를 사용하여 FaultException 클래스의 새 인스턴스를 초기화합니다.

FaultException(String, FaultCode, String)

지정된 원인, 오류 코드 및 동작 값을 사용하여 FaultException 클래스의 새 인스턴스를 초기화합니다.

속성

Action

오류 메시지의 SOAP 동작 값을 가져옵니다.

Code

SOAP 오류에 대한 오류 코드를 가져옵니다.

Data

예외에 대한 사용자 정의 정보를 추가로 제공하는 키/값 쌍 컬렉션을 가져옵니다.

(다음에서 상속됨 Exception)
HelpLink

이 예외와 연결된 도움말 파일에 대한 링크를 가져오거나 설정합니다.

(다음에서 상속됨 Exception)
HResult

특정 예외에 할당된 코드화된 숫자 값인 HRESULT를 가져오거나 설정합니다.

(다음에서 상속됨 Exception)
InnerException

현재 예외를 발생시킨 Exception 인스턴스를 가져옵니다.

(다음에서 상속됨 Exception)
Message

예외에 대한 메시지를 가져옵니다.

Reason

SOAP 오류의 FaultReason을 가져옵니다.

Source

오류를 발생시키는 애플리케이션 또는 개체의 이름을 가져오거나 설정합니다.

(다음에서 상속됨 Exception)
StackTrace

호출 스택의 직접 실행 프레임 문자열 표현을 가져옵니다.

(다음에서 상속됨 Exception)
TargetSite

현재 예외를 throw하는 메서드를 가져옵니다.

(다음에서 상속됨 Exception)

메서드

CreateFault(MessageFault, String, Type[])

지정된 메시지 오류, 동작 및 세부 형식의 배열에서 FaultException 개체를 반환합니다.

CreateFault(MessageFault, Type[])

지정된 메시지 오류 및 세부 형식의 배열에서 FaultException 개체를 반환합니다.

CreateMessageFault()

MessageFault 개체를 반환합니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetBaseException()

파생 클래스에서 재정의된 경우 하나 이상의 후속 예외의 근본 원인이 되는 Exception 을 반환합니다.

(다음에서 상속됨 Exception)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetObjectData(SerializationInfo, StreamingContext)

개체가 스트림으로 serialize될 때 호출되는 GetObjectData(SerializationInfo, StreamingContext) 메서드의 구현입니다.

GetObjectData(SerializationInfo, StreamingContext)

파생 클래스에서 재정의된 경우 예외에 관한 정보를 SerializationInfo 에 설정합니다.

(다음에서 상속됨 Exception)
GetType()

현재 인스턴스의 런타임 형식을 가져옵니다.

(다음에서 상속됨 Exception)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 예외에 대한 문자열 표현을 만들고 반환합니다.

(다음에서 상속됨 Exception)

이벤트

SerializeObjectState
사용되지 않습니다.

예외에 대한 serialize된 데이터가 들어 있는 예외 상태 개체가 만들어지도록 예외가 serialize될 때 발생합니다.

(다음에서 상속됨 Exception)

적용 대상