CallbackBehaviorAttribute 클래스

정의

클라이언트 애플리케이션에서 콜백 서비스 구현을 구성합니다.

public ref class CallbackBehaviorAttribute sealed : Attribute, System::ServiceModel::Description::IEndpointBehavior
[System.AttributeUsage(System.AttributeTargets.Class)]
public sealed class CallbackBehaviorAttribute : Attribute, System.ServiceModel.Description.IEndpointBehavior
[<System.AttributeUsage(System.AttributeTargets.Class)>]
type CallbackBehaviorAttribute = class
    inherit Attribute
    interface IEndpointBehavior
Public NotInheritable Class CallbackBehaviorAttribute
Inherits Attribute
Implements IEndpointBehavior
상속
CallbackBehaviorAttribute
특성
구현

예제

다음 코드 예제에서는 개체를 사용하여 SynchronizationContext 마샬링할 스레드, ValidateMustUnderstand 메시지 유효성 검사를 적용할 속성 및 IncludeExceptionDetailInFaults 디버깅을 위해 서비스에 개체로 FaultException 예외를 반환하는 속성을 결정하는 콜백 개체를 보여 CallbackBehaviorAttribute 줍니다.

using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Threading;

namespace Microsoft.WCF.Documentation
{
  [CallbackBehaviorAttribute(
   IncludeExceptionDetailInFaults= true,
    UseSynchronizationContext=true,
    ValidateMustUnderstand=true
  )]
  public class Client : SampleDuplexHelloCallback
  {
    AutoResetEvent waitHandle;

    public Client()
    {
      waitHandle = new AutoResetEvent(false);
    }

    public void Run()
    {
      // Picks up configuration from the configuration file.
      SampleDuplexHelloClient wcfClient
        = new SampleDuplexHelloClient(new InstanceContext(this), "WSDualHttpBinding_SampleDuplexHello");
      try
      {
        Console.ForegroundColor = ConsoleColor.White;
        Console.WriteLine("Enter a greeting to send and press ENTER: ");
        Console.Write(">>> ");
        Console.ForegroundColor = ConsoleColor.Green;
        string greeting = Console.ReadLine();
        Console.ForegroundColor = ConsoleColor.White;
        Console.WriteLine("Called service with: \r\n\t" + greeting);
        wcfClient.Hello(greeting);
        Console.WriteLine("Execution passes service call and moves to the WaitHandle.");
        this.waitHandle.WaitOne();
        Console.ForegroundColor = ConsoleColor.Blue;
        Console.WriteLine("Set was called.");
        Console.Write("Press ");
        Console.ForegroundColor = ConsoleColor.Red;
        Console.Write("ENTER");
        Console.ForegroundColor = ConsoleColor.Blue;
        Console.Write(" to exit...");
        Console.ReadLine();
      }
      catch (TimeoutException timeProblem)
      {
        Console.WriteLine("The service operation timed out. " + timeProblem.Message);
        Console.ReadLine();
      }
      catch (CommunicationException commProblem)
      {
        Console.WriteLine("There was a communication problem. " + commProblem.Message);
        Console.ReadLine();
      }
    }
    public static void Main()
    {
      Client client = new Client();
      client.Run();
    }

    public void Reply(string response)
    {
      Console.WriteLine("Received output.");
      Console.WriteLine("\r\n\t" + response);
      this.waitHandle.Set();
    }
  }
}

Imports System.ServiceModel
Imports System.ServiceModel.Channels
Imports System.Threading

Namespace Microsoft.WCF.Documentation
  <CallbackBehaviorAttribute(IncludeExceptionDetailInFaults:= True, UseSynchronizationContext:=True, ValidateMustUnderstand:=True)> _
  Public Class Client
      Implements SampleDuplexHelloCallback
    Private waitHandle As AutoResetEvent

    Public Sub New()
      waitHandle = New AutoResetEvent(False)
    End Sub

    Public Sub Run()
      ' Picks up configuration from the configuration file.
      Dim wcfClient As New SampleDuplexHelloClient(New InstanceContext(Me), "WSDualHttpBinding_SampleDuplexHello")
      Try
        Console.ForegroundColor = ConsoleColor.White
        Console.WriteLine("Enter a greeting to send and press ENTER: ")
        Console.Write(">>> ")
        Console.ForegroundColor = ConsoleColor.Green
        Dim greeting As String = Console.ReadLine()
        Console.ForegroundColor = ConsoleColor.White
        Console.WriteLine("Called service with: " & Constants.vbCrLf & Constants.vbTab & greeting)
        wcfClient.Hello(greeting)
        Console.WriteLine("Execution passes service call and moves to the WaitHandle.")
        Me.waitHandle.WaitOne()
        Console.ForegroundColor = ConsoleColor.Blue
        Console.WriteLine("Set was called.")
        Console.Write("Press ")
        Console.ForegroundColor = ConsoleColor.Red
        Console.Write("ENTER")
        Console.ForegroundColor = ConsoleColor.Blue
        Console.Write(" to exit...")
        Console.ReadLine()
      Catch timeProblem As TimeoutException
        Console.WriteLine("The service operation timed out. " & timeProblem.Message)
        Console.ReadLine()
      Catch commProblem As CommunicationException
        Console.WriteLine("There was a communication problem. " & commProblem.Message)
        Console.ReadLine()
      End Try
    End Sub
    Public Shared Sub Main()
      Dim client As New Client()
      client.Run()
    End Sub

    Public Sub Reply(ByVal response As String) Implements SampleDuplexHelloCallback.Reply
      Console.WriteLine("Received output.")
      Console.WriteLine(Constants.vbCrLf & Constants.vbTab & response)
      Me.waitHandle.Set()
    End Sub
  End Class
End Namespace

설명

CallbackBehaviorAttribute 특성을 사용하여 클라이언트 애플리케이션에서 콜백 계약 구현의 실행 동작을 구성하거나 확장할 수 있습니다. 이 특성은 인스턴스화 동작 및 트랜잭션 설정을 제외하고 특성과 콜 ServiceBehaviorAttribute 백 클래스에 대해 동일한 함수를 수행합니다.

CallbackBehaviorAttribute 콜백 계약을 구현하는 클래스에 적용해야 합니다. 이중이 아닌 계약 구현에 적용되는 경우 런타임에 InvalidOperationException 예외가 throw됩니다.

참고

콜백 작업 구현에 특성을 사용할 OperationBehaviorAttribute 수도 있습니다. 그러나 콜백 작업에 사용되는 경우 OperationBehaviorAttribute 속성은 런타임에 ReleaseInstanceMode throw되거나 예외가 throw되어야 None InvalidOperationException 합니다.

사용할 수 있는 속성은 다음과 같습니다.

  • 채널이 AutomaticSessionShutdown 닫혀 콜백이 나머지 메시지 처리를 완료하면 속성이 세션을 자동으로 닫습니다.

  • 이 속성은 ConcurrencyMode 내부 스레딩 모델을 제어하여 재진입 또는 다중 스레드 콜백 개체를 지원합니다.

  • IgnoreExtensionDataObject 속성을 사용하면 런타임에서 메시지를 처리하는 데 필요하지 않은 추가 serialization 정보를 무시할 수 있습니다.

  • 이 속성은 IncludeExceptionDetailInFaults 디버깅을 위해 서비스의 처리되지 않은 예외가 SOAP 오류로 서비스에 반환되는지 여부를 지정합니다.

  • MaxItemsInObjectGraph 직렬화된 개체 그래프의 항목 수에 대한 속성 제한입니다.

  • TransactionIsolationLevel 속성은 계약이 지원하는 트랜잭션 격리 수준을 지정합니다.

  • TransactionTimeout 속성은 트랜잭션 완료가 이루어지지 않으면 중단되는 기간을 지정합니다.

  • 이 속성은 UseSynchronizationContext 현재 SynchronizationContext 개체를 사용하여 인바운드 메서드 호출을 자동으로 동기화할지 여부를 나타냅니다.

  • ValidateMustUnderstand 속성은 MustUnderstand로 표시된 SOAP 헤더가 실제로 인식되었음을 확인해야 하는지 여부를 시스템에 알려 줍니다.

생성자

CallbackBehaviorAttribute()

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

속성

AutomaticSessionShutdown

서비스가 이중 세션을 닫을 때 자동으로 세션을 닫을지 여부를 지정합니다.

ConcurrencyMode

서비스가 하나의 스레드, 여러 개의 스레드 또는 재진입 호출을 지원할지 여부를 가져오거나 설정합니다.

IgnoreExtensionDataObject

네트워크에서 알 수 없는 serialization 데이터를 보낼지 여부를 지정하는 값을 가져오거나 설정합니다.

IncludeExceptionDetailInFaults

일반적인 처리되지 않은 실행 예외를 FaultException<TDetail> 형식의 String으로 변환하고 오류 메시지로 보내도록 지정하는 값을 가져오거나 설정합니다. 서비스 문제를 해결하려면 개발하는 동안에만 이 값을 true로 설정합니다.

MaxItemsInObjectGraph

serialize된 개체에 허용되는 최대 항목 수를 가져오거나 설정합니다.

TransactionIsolationLevel

트랜잭션 격리 수준을 지정합니다.

TransactionTimeout

트랜잭션을 완료해야 하는 기간을 가져오거나 설정합니다.

TypeId

파생 클래스에서 구현된 경우 이 Attribute에 대한 고유 식별자를 가져옵니다.

(다음에서 상속됨 Attribute)
UseSynchronizationContext

현재 동기화 컨텍스트를 사용하여 실행 스레드를 선택할지 여부를 지정하는 값을 가져오거나 설정합니다.

ValidateMustUnderstand

SOAP MustUnderstand 헤더 처리를 시스템에서 수행하는지 아니면 애플리케이션에서 수행하는지를 지정하는 값을 가져오거나 설정합니다.

메서드

Equals(Object)

이 인스턴스가 지정된 개체와 같은지를 나타내는 값을 반환합니다.

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

이 인스턴스의 해시 코드를 반환합니다.

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

현재 인스턴스의 Type을 가져옵니다.

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

파생 클래스에서 재정의된 경우 이 인스턴스 값이 파생 클래스에 대한 기본값인지 여부를 표시합니다.

(다음에서 상속됨 Attribute)
Match(Object)

파생 클래스에서 재정의된 경우 이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다.

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

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

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

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

명시적 인터페이스 구현

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

이름 집합을 해당하는 디스패치 식별자 집합에 매핑합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

인터페이스의 형식 정보를 가져오는 데 사용할 수 있는 개체의 형식 정보를 검색합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

개체에서 제공하는 형식 정보 인터페이스의 수를 검색합니다(0 또는 1).

(다음에서 상속됨 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

개체에서 노출하는 메서드와 속성에 대한 액세스를 제공합니다.

(다음에서 상속됨 Attribute)
IEndpointBehavior.AddBindingParameters(ServiceEndpoint, BindingParameterCollection)

콜백 동작을 지원하도록 바인딩 요소를 구성합니다.

IEndpointBehavior.ApplyClientBehavior(ServiceEndpoint, ClientRuntime)

콜백 개체를 지원하도록 클라이언트 런타임을 구성합니다.

IEndpointBehavior.ApplyDispatchBehavior(ServiceEndpoint, EndpointDispatcher)

ApplyDispatchBehavior(ServiceEndpoint, EndpointDispatcher) 메서드의 구현입니다. 이 구현은 아무 작업도 수행하지 않습니다.

IEndpointBehavior.Validate(ServiceEndpoint)

런타임을 빌드하기 전에 엔드포인트 설명의 유효성을 검사합니다.

적용 대상