다음을 통해 공유


오류 처리 기능 사용

WCF(Windows Communication Foundation) 동안 예외 메시지를 처리하는 동안 FaultException (또는 하위 형식)이 throw되거나 FaultContract 가 구현되지 않는 한 예외 메시지가 클라이언트에 반환되지 않습니다. 따라서 이러한 시나리오에서는 오류 메시지의 데이터만 추적할 수 있습니다. 콜백 구현의 예외는 ServerFaultClientFault 트랙 지점 모두에 대한 오류 메시지로 자동으로 반환됩니다. 그러나 항상 일반 메시지와 함께 일반 오류가 반환됩니다. WCF 오류 계약에 대한 자세한 내용은 을 참조하세요 https://go.microsoft.com/fwlink/?LinkId=83132.

오류 추적 지점을 통해 상수 및 컨텍스트 속성도 추적할 수 있습니다.

IncludeExceptionDetailInFaults 특성을 사용하여 오류에 예외 세부 정보가 반환되는 경우 XPath를 통해 실제 예외 메시지를 추출합니다.

오류 처리는 GetServiceContractCallPoint에 정의된 오류 트랙 지점에서 제공됩니다.

  • ServiceFault

  • ClientFault

  • CallbackFault

    이러한 오류 추적 지점을 사용할 때는 트랜잭션 기반 시나리오에서 작업을 할 때도 오류 데이터가 항상 유지됩니다. 오류를 추적하지 않는 모든 데이터에서 트랜잭션 무결성이 유지 관리되며 오류를 추적하지 않는 데이터는 오류에 대한 응답으로 롤백됩니다.

참고

이러한 추적 지점은 회신 경로에 적용되며 GetServiceContractCallPoint에서 제공하는 ServiceReply, ClientReply 및 CallbackReply 서비스 계약 호출 지점에만 적용됩니다.

오류 구성 샘플

다음 샘플에서는 서비스가 AuthorizationServiceFault 이벤트에서 FaultException을 throw할 때 ServiceFault에서 예외 메시지를 추적하는 방법을 보여 줍니다. 그렇지 않으면 AuthorizationServiceReply 이벤트의 작업에서 반환된 부울 식을 추적합니다. AuthorizationServiceReply OnEvent 또는 AuthorizationServiceFault OnEvent가 유지됩니다.

참고

이 샘플의 구현에서는 ServiceReply 및 ServiceFault 추적 지점을 함께 사용할 수 없음을 보여 줍니다.

<ic:OnEvent IsBegin ="true" IsEnd="false" Name="AuthorizationServiceReply" Source="ESCreditCardService">

  <ic:Filter>
    <ic:Expression>
      <wcf:Operation Name="GetServiceContractCallPoint"/>
      <ic:Operation Name ="Constant">
        <ic:Argument>ServiceReply</ic:Argument>
      </ic:Operation>
      <ic:Operation Name ="Equals"/>
      <wcf:Operation Name="GetOperationName" />
      <ic:Operation Name="Constant">
        <ic:Argument>AuthorizeWithDataContract</ic:Argument>
      </ic:Operation>
      <ic:Operation Name ="Equals" />
      <ic:Operation Name ="And" />
    </ic:Expression>
  </ic:Filter>

  <ic:CorrelationID>
    <ic:Expression>
      <wcf:Operation Name="AutoGenerateCorrelationToken"/>
    </ic:Expression>
  </ic:CorrelationID>

  <ic:Update DataItemName="Status" Type="NVARCHAR">
    <ic:Expression>
      <ic:Operation Name="Constant">
        <ic:Argument>Success</ic:Argument>
      </ic:Operation>
    </ic:Expression>
  </ic:Update>

  <ic:Update DataItemName="Result" Type="NVARCHAR">
    <ic:Expression>
      <wcf:Operation Name ="XPath">
        <wcf:Argument>//s:Body/ccservice:*/ccservice:AuthorizeWithDataContractResult</wcf:Argument>
      </wcf:Operation>
    </ic:Expression>
  </ic:Update>

  <ic:Update DataItemName ="Service Call Date" Type ="DATETIME">
    <ic:Expression>
      <wcf:Operation Name ="GetContextProperty">
        <wcf:Argument>EventTime</wcf:Argument>
      </wcf:Operation>
    </ic:Expression>
  </ic:Update>

</ic:OnEvent>

<ic:OnEvent IsBegin ="true" IsEnd="false" Name="AuthorizationServiceFault" Source="ESCreditCardService">

  <ic:Filter>
    <ic:Expression>
      <wcf:Operation Name="GetServiceContractCallPoint"/>
      <ic:Operation Name ="Constant">
        <ic:Argument>ServiceFault</ic:Argument>
      </ic:Operation>
      <ic:Operation Name ="Equals"/>
      <wcf:Operation Name="GetOperationName" />
      <ic:Operation Name="Constant">
        <ic:Argument>AuthorizeWithDataContract</ic:Argument>
      </ic:Operation>
      <ic:Operation Name ="Equals" />
      <ic:Operation Name ="And" />
    </ic:Expression>
  </ic:Filter>

  <ic:CorrelationID>
    <ic:Expression>
      <wcf:Operation Name="AutoGenerateCorrelationToken"/>
    </ic:Expression>
  </ic:CorrelationID>

  <ic:Update DataItemName="Status" Type="NVARCHAR">
    <ic:Expression>
      <ic:Operation Name="Constant">
        <ic:Argument>Fault</ic:Argument>
      </ic:Operation>
    </ic:Expression>
  </ic:Update>

      <ic:Update DataItemName="Source" Type="NVARCHAR">
        <ic:Expression>
          <wcf:Operation Name ="XPath">
            <wcf:Argument>//s:Body/Fault/Reason/Text</wcf:Argument>
          </wcf:Operation>
        </ic:Expression>
      </ic:Update>

  <ic:Update DataItemName ="Service Call Date" Type ="DATETIME">
    <ic:Expression>
      <wcf:Operation Name ="GetContextProperty">
        <wcf:Argument>EventTime</wcf:Argument>
      </wcf:Operation>
    </ic:Expression>
  </ic:Update>

</ic:OnEvent>

참고 항목

BAM 데이터를 가로채도록 WCF 어댑터 구성