ChannelFactory 클래스

정의

클라이언트에서 서비스 엔드포인트로 메시지를 보낼 때 사용하는 채널을 만들고 관리합니다.

public ref class ChannelFactory abstract : System::ServiceModel::Channels::CommunicationObject, IDisposable, System::ServiceModel::Channels::IChannelFactory
public abstract class ChannelFactory : System.ServiceModel.Channels.CommunicationObject, IDisposable, System.ServiceModel.Channels.IChannelFactory
type ChannelFactory = class
    inherit CommunicationObject
    interface IDisposable
    interface IChannelFactory
    interface ICommunicationObject
type ChannelFactory = class
    inherit CommunicationObject
    interface IChannelFactory
    interface ICommunicationObject
    interface IDisposable
Public MustInherit Class ChannelFactory
Inherits CommunicationObject
Implements IChannelFactory, IDisposable
상속
ChannelFactory
파생
구현

예제

다음 코드 예제에서는 팩터리에서 채널 개체를 만들기 전에 클라이언트 동작을 프로그래밍 방식으로 삽입하는 방법을 보여 줍니다.

public class Client
{
  public static void Main()
  {
    try
    {
      // Picks up configuration from the config file.
      ChannelFactory<ISampleServiceChannel> factory
        = new ChannelFactory<ISampleServiceChannel>("WSHttpBinding_ISampleService");

      // Add the client side behavior programmatically to all created channels.
      factory.Endpoint.Behaviors.Add(new EndpointBehaviorMessageInspector());

      ISampleServiceChannel wcfClientChannel = factory.CreateChannel();

      // Making calls.
      Console.WriteLine("Enter the greeting to send: ");
      string greeting = Console.ReadLine();
      Console.WriteLine("The service responded: " + wcfClientChannel.SampleMethod(greeting));

      Console.WriteLine("Press ENTER to exit:");
      Console.ReadLine();

      // Done with service.
      wcfClientChannel.Close();
      Console.WriteLine("Done!");
    }
    catch (TimeoutException timeProblem)
    {
      Console.WriteLine("The service operation timed out. " + timeProblem.Message);
      Console.Read();
    }
    catch (FaultException<SampleFault> fault)
    {
      Console.WriteLine("SampleFault fault occurred: {0}", fault.Detail.FaultMessage);
      Console.Read();
    }
    catch (CommunicationException commProblem)
    {
      Console.WriteLine("There was a communication problem. " + commProblem.Message);
      Console.Read();
    }
  }
Public Class Client
  Public Shared Sub Main()
    Try
      ' Picks up configuration from the config file.
      Dim factory As New ChannelFactory(Of ISampleServiceChannel)("WSHttpBinding_ISampleService")

      ' Add the client side behavior programmatically to all created channels.
      factory.Endpoint.Behaviors.Add(New EndpointBehaviorMessageInspector())

      Dim wcfClientChannel As ISampleServiceChannel = factory.CreateChannel()

      ' Making calls.
      Console.WriteLine("Enter the greeting to send: ")
            Dim greeting As String = Console.ReadLine()
      Console.WriteLine("The service responded: " & wcfClientChannel.SampleMethod(greeting))

      Console.WriteLine("Press ENTER to exit:")
      Console.ReadLine()

      ' Done with service. 
      wcfClientChannel.Close()
      Console.WriteLine("Done!")
    Catch timeProblem As TimeoutException
      Console.WriteLine("The service operation timed out. " & timeProblem.Message)
      Console.Read()
    Catch fault As FaultException(Of SampleFault)
      Console.WriteLine("SampleFault fault occurred: {0}", fault.Detail.FaultMessage)
      Console.Read()
    Catch commProblem As CommunicationException
      Console.WriteLine("There was a communication problem. " & commProblem.Message)
      Console.Read()
    End Try
  End Sub

설명

IChannelFactory 인터페이스를 구현하는 채널 팩터리 및 관련 채널은 일반적으로 통신 패턴의 개시자에서 사용됩니다. IChannelListener 인터페이스를 구현하는 수신기 팩터리 및 관련 수신기는 통신을 위해 채널을 수락하는 메커니즘을 제공합니다.

이 클래스는 채널 모델이 아니라 서비스 모델에 속해 있습니다. CreateFactory 메서드를 사용하면 서비스 엔드포인트에 대한 IChannelFactory를 만들 수 있습니다. 메타데이터나 정책을 사용하지 않고 서비스에서 인터페이스 계약에 연결되는 클라이언트를 생성할 때 이 메서드를 사용합니다.

참고

ChannelFactory.Credentials.Windows.AllowedImpersonationLevelTokenImpersonationLevel.Anonymous로 설정하면 가장 수준과 관계없이 항상 익명 로그온이 수행됩니다.

이 클래스에서 파생된 Managed C++ 사용자 관련 참고 사항:

  • 소멸자가 아니라 (On)(Begin)Close 및/또는 OnAbort에 정리 코드를 입력하십시오.

  • 소멸자를 사용하지 마십시오. 소멸자를 사용하면 컴파일러에서 IDisposable을 자동으로 생성할 수 있습니다.

  • 비참조 멤버를 사용하지 마십시오. 비참조 멤버를 사용하면 컴파일러에서 IDisposable을 자동으로 생성할 수 있습니다.

  • 종료자를 사용하지 마십시오. 그러나 종료자를 포함하는 경우 자동으로 생성되는 SuppressFinalize(Object) 동작을 에뮬레이트하기 위해 빌드 경고를 표시하지 않고 (On)(Begin)Close 및/또는 OnAbort에서 IDisposable 및 해당 종료자를 호출해야 합니다.

동작을 프로그래밍 방식으로 추가할 경우 동작은 채널이 만들어지기 이전에 Behaviors의 적절한 ChannelFactory 속성에 추가됩니다. 코드 예제는 예제 단원을 참조하십시오.

생성자

ChannelFactory()

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

속성

Credentials

팩터리에서 생성한 채널을 통해 클라이언트가 서비스 엔드포인트와 통신할 때 사용하는 자격 증명을 가져옵니다.

DefaultCloseTimeout

닫기 작업을 완료하기 위해 제공되는 기본 시간 간격을 가져옵니다.

DefaultOpenTimeout

열기 작업을 완료하기 위해 제공되는 기본 시간 간격을 가져옵니다.

Endpoint

팩터리에서 만든 채널이 연결되는 서비스 엔드포인트를 가져옵니다.

IsDisposed

통신 개체가 삭제되었는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 CommunicationObject)
State

통신 개체의 현재 상태를 나타내는 값을 가져옵니다.

(다음에서 상속됨 CommunicationObject)
ThisLock

상태 전환 중에 클래스 인스턴스를 보호하는 상호 배타적인 전용 잠금을 가져옵니다.

(다음에서 상속됨 CommunicationObject)

메서드

Abort()

통신 개체가 현재 상태에서 Closing 상태로 즉시 전환되도록 합니다.

(다음에서 상속됨 CommunicationObject)
ApplyConfiguration(String)

지정된 구성 파일에서 제공한 동작 및 채널 팩터리의 서비스 엔드포인트에 있는 동작을 통해 채널 팩터리를 초기화합니다.

BeginClose(AsyncCallback, Object)

통신 개체를 닫기 위한 비동기 작업을 시작합니다.

(다음에서 상속됨 CommunicationObject)
BeginClose(TimeSpan, AsyncCallback, Object)

지정된 제한 시간 내에서 통신 개체를 닫기 위한 비동기 작업을 시작합니다.

(다음에서 상속됨 CommunicationObject)
BeginOpen(AsyncCallback, Object)

통신 개체를 열기 위한 비동기 작업을 시작합니다.

(다음에서 상속됨 CommunicationObject)
BeginOpen(TimeSpan, AsyncCallback, Object)

지정된 시간 간격 내에서 통신 개체를 열기 위한 비동기 작업을 시작합니다.

(다음에서 상속됨 CommunicationObject)
Close()

통신 개체가 현재 상태에서 Closed 상태로 전환되도록 합니다.

(다음에서 상속됨 CommunicationObject)
Close(TimeSpan)

통신 개체가 지정된 시간 간격 내에 현재 상태에서 Closed 상태로 전환되도록 합니다.

(다음에서 상속됨 CommunicationObject)
CreateDescription()

파생 클래스에서 구현되는 경우 채널 팩터리와 연결된 서비스 엔드포인트에 대한 설명을 만듭니다.

CreateFactory()

팩터리의 현재 엔드포인트에 대해 채널 팩터리를 생성합니다.

EndClose(IAsyncResult)

통신 개체를 닫기 위한 비동기 작업을 완료합니다.

(다음에서 상속됨 CommunicationObject)
EndOpen(IAsyncResult)

통신 개체를 열기 위한 비동기 작업을 완료합니다.

(다음에서 상속됨 CommunicationObject)
EnsureOpened()

현재 채널 팩터리가 아직 열리지 않은 경우 이를 엽니다.

Equals(Object)

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

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

통신 개체가 현재 상태에서 Faulted 상태로 전환되도록 합니다.

(다음에서 상속됨 CommunicationObject)
GetCommunicationObjectType()

통신 개체의 형식을 가져옵니다.

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

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

(다음에서 상속됨 Object)
GetProperty<T>()

요청한 형식의 개체가 있으면 채널 스택의 해당 계층에서 그 개체를 반환하고, 개체가 없으면 null을 반환합니다.

GetType()

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

(다음에서 상속됨 Object)
InitializeEndpoint(Binding, EndpointAddress)

지정된 바인딩 및 주소를 사용하여 채널 팩터리의 서비스 엔드포인트를 초기화합니다.

InitializeEndpoint(ServiceEndpoint)

지정된 엔드포인트를 사용하여 채널 팩터리의 서비스 엔드포인트를 초기화합니다.

InitializeEndpoint(String, EndpointAddress)

지정된 주소 및 구성을 사용하여 채널 팩터리의 서비스 엔드포인트를 초기화합니다.

MemberwiseClone()

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

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

현재 채널 팩터리의 내부 채널 팩터리를 종료합니다.

OnBeginClose(TimeSpan, AsyncCallback, Object)

연결된 상태 개체가 있는 현재 채널 팩터리의 내부 채널 팩터리에서 비동기 닫기 작업을 시작합니다.

OnBeginOpen(TimeSpan, AsyncCallback, Object)

연결된 상태 개체가 있는 현재 채널 팩터리의 내부 채널 팩터리에서 비동기 열기 작업을 시작합니다.

OnClose(TimeSpan)

작업 완료를 위해 지정된 시간 제한을 사용하여 내부 채널 팩터리에 대한 닫기를 호출합니다.

OnClosed()

통신 개체가 Closing 상태로 전환되는 중에 호출됩니다.

(다음에서 상속됨 CommunicationObject)
OnClosing()

통신 개체가 Closing 상태로 전환되는 중에 호출됩니다.

(다음에서 상속됨 CommunicationObject)
OnEndClose(IAsyncResult)

현재 채널 팩터리의 내부 채널 팩터리에 대한 비동기 닫기 작업을 완료합니다.

OnEndOpen(IAsyncResult)

현재 채널 팩터리의 내부 채널 팩터리에 대한 비동기 열기 작업을 완료합니다.

OnFaulted()

통신 개체가 동기 오류 작업의 호출로 인해 Faulted 상태로 전환된 후 해당 통신 개체에 대한 처리를 삽입합니다.

(다음에서 상속됨 CommunicationObject)
OnOpen(TimeSpan)

작업 완료를 위해 지정된 시간 제한을 사용하여 현재 채널 팩터리의 내부 채널 팩터리에 대한 열기를 호출합니다.

OnOpened()

채널 팩터리에 대한 ClientCredentials 개체의 읽기 전용 복사본을 초기화합니다.

OnOpening()

현재 채널의 내부 채널 팩터리를 생성합니다.

Open()

통신 개체가 Created 상태에서 Opened 상태로 전환되도록 합니다.

(다음에서 상속됨 CommunicationObject)
Open(TimeSpan)

통신 개체가 지정된 시간 간격 내에 Created 상태에서 Opened 상태로 전환되도록 합니다.

(다음에서 상속됨 CommunicationObject)
ThrowIfDisposed()

통신 개체가 삭제되면 예외를 throw합니다.

(다음에서 상속됨 CommunicationObject)
ThrowIfDisposedOrImmutable()

통신 개체의 State 속성이 Created 상태로 설정되지 않은 경우 예외를 throw합니다.

(다음에서 상속됨 CommunicationObject)
ThrowIfDisposedOrNotOpen()

통신 개체가 Opened 상태가 아니면 예외를 throw합니다.

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

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

(다음에서 상속됨 Object)

이벤트

Closed

통신 개체가 Closed 상태로 전환될 때 발생합니다.

(다음에서 상속됨 CommunicationObject)
Closing

통신 개체가 Closing 상태로 전환될 때 발생합니다.

(다음에서 상속됨 CommunicationObject)
Faulted

통신 개체가 Faulted 상태로 전환될 때 발생합니다.

(다음에서 상속됨 CommunicationObject)
Opened

통신 개체가 Opened 상태로 전환될 때 발생합니다.

(다음에서 상속됨 CommunicationObject)
Opening

통신 개체가 Opening 상태로 전환될 때 발생합니다.

(다음에서 상속됨 CommunicationObject)

명시적 인터페이스 구현

IDisposable.Dispose()

현재 채널 팩터리를 닫습니다.

적용 대상