ChannelFactory<TChannel> 클래스

정의

다양하게 구성된 서비스 엔드포인트로 메시지를 보내는 데 클라이언트에서 사용하는 여러 형식의 채널을 만드는 팩터리입니다.

generic <typename TChannel>
public ref class ChannelFactory : System::ServiceModel::ChannelFactory, System::ServiceModel::Channels::IChannelFactory<TChannel>
public class ChannelFactory<TChannel> : System.ServiceModel.ChannelFactory, System.ServiceModel.Channels.IChannelFactory<TChannel>
type ChannelFactory<'Channel> = class
    inherit ChannelFactory
    interface IChannelFactory
    interface ICommunicationObject
    interface IChannelFactory<'Channel>
type ChannelFactory<'Channel> = class
    inherit ChannelFactory
    interface IChannelFactory<'Channel>
    interface IChannelFactory
    interface ICommunicationObject
Public Class ChannelFactory(Of TChannel)
Inherits ChannelFactory
Implements IChannelFactory(Of TChannel)

형식 매개 변수

TChannel

채널 팩터리에서 생성하는 채널 형식입니다. 이 형식은 IOutputChannel 또는 IRequestChannel이어야 합니다.

상속
ChannelFactory<TChannel>
파생
구현

예제

다음 예제에서는 채널 팩터리를 만드는 방법과 이 채널 팩터리를 사용하여 채널을 만들고 관리하는 방법을 보여 줍니다.

    BasicHttpBinding binding = new BasicHttpBinding();
    EndpointAddress address = new EndpointAddress("http://localhost:8000/ChannelApp");

    ChannelFactory<IRequestChannel> factory =
        new ChannelFactory<IRequestChannel>(binding, address);

    IRequestChannel channel = factory.CreateChannel();
    channel.Open();
    Message request = Message.CreateMessage(MessageVersion.Soap11, "hello");
    Message reply = channel.Request(request);
    Console.Out.WriteLine(reply.Headers.Action);
    reply.Close();
    channel.Close();
    factory.Close();
}

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

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

설명

이 제네릭 클래스를 사용하면 두 가지 이상의 채널 형식을 만드는 데 사용할 수 있는 채널 팩터리를 만들어야 하는 고급 시나리오를 사용할 수 있습니다.

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

이 형식을 사용하는 클라이언트 또는 호출 애플리케이션(예를 들어 중간 계층 애플리케이션도 클라이언트 애플리케이션임)에도 복잡한 상태 관리 요구 사항과 성능 요구 사항이 있는 경우가 많습니다. 이러한 시나리오에 대 한 자세한 내용은 참조 하십시오 중간 계층 클라이언트 애플리케이션합니다.

생성자

ChannelFactory<TChannel>()

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

ChannelFactory<TChannel>(Binding)

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

ChannelFactory<TChannel>(Binding, EndpointAddress)

지정된 바인딩 및 엔드포인트 주소를 사용하여 ChannelFactory<TChannel> 클래스의 새 인스턴스를 초기화합니다.

ChannelFactory<TChannel>(Binding, String)

지정된 바인딩 및 원격 주소를 사용하여 ChannelFactory<TChannel> 클래스의 새 인스턴스를 초기화합니다.

ChannelFactory<TChannel>(ServiceEndpoint)

지정된 엔드포인트를 사용하여 채널을 생성하는 ChannelFactory<TChannel> 클래스의 새 인스턴스를 초기화합니다.

ChannelFactory<TChannel>(String)

지정된 엔드포인트 구성 이름을 사용하여 ChannelFactory<TChannel> 클래스의 새 인스턴스를 초기화합니다.

ChannelFactory<TChannel>(String, EndpointAddress)

엔드포인트 구성 및 원격 주소의 지정된 이름과 연결된 ChannelFactory<TChannel> 클래스의 새 인스턴스를 초기화합니다.

ChannelFactory<TChannel>(Type)

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

속성

Credentials

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

(다음에서 상속됨 ChannelFactory)
DefaultCloseTimeout

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

(다음에서 상속됨 ChannelFactory)
DefaultOpenTimeout

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

(다음에서 상속됨 ChannelFactory)
Endpoint

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

(다음에서 상속됨 ChannelFactory)
IsDisposed

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

(다음에서 상속됨 CommunicationObject)
State

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

(다음에서 상속됨 CommunicationObject)
ThisLock

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

(다음에서 상속됨 CommunicationObject)

메서드

Abort()

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

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

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

(다음에서 상속됨 ChannelFactory)
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)
CreateChannel()

지정된 엔드포인트 주소에 대해 지정된 형식의 채널을 만듭니다.

CreateChannel(Binding, EndpointAddress)

지정된 바인딩으로 구성된 서비스 엔드포인트에 메시지를 보내는 데 사용되는 지정된 형식의 채널을 만듭니다.

CreateChannel(Binding, EndpointAddress, Uri)

지정된 바인딩으로 구성된 지정된 전송 주소에서 서비스 엔드포인트에 메시지를 보내는 데 사용되는 지정된 형식의 채널을 만듭니다.

CreateChannel(EndpointAddress)

지정된 엔드포인트 주소에서 서비스에 메시지를 보내는 데 사용되는 채널을 만듭니다.

CreateChannel(EndpointAddress, Uri)

지정된 전송 주소를 통해 특정 엔드포인트 주소에서 서비스에 메시지를 보내는 데 사용되는 채널을 만듭니다.

CreateChannel(String)

엔드포인트가 지정된 방식으로 구성된 서비스에 메시지를 보내는 데 사용되는 채널을 만듭니다.

CreateChannelWithActAsToken(SecurityToken)

Act As 보안 토큰을 사용하여 서비스에 메시지를 보내는 데 사용되는 채널을 만듭니다.

CreateChannelWithActAsToken(SecurityToken, EndpointAddress)

지정된 엔드포인트 주소에서 보안 토큰을 사용하여 서비스에 메시지를 보내는 데 사용되는 채널을 만듭니다.

CreateChannelWithActAsToken(SecurityToken, EndpointAddress, Uri)

지정된 전송 주소를 통해 특정 엔드포인트 주소에서 보안 토큰으로 사용할 서비스에 메시지를 보내는 데 사용되는 채널을 만듭니다.

CreateChannelWithIssuedToken(SecurityToken)

발급된 보안 토큰을 사용하여 서비스에 메시지를 보내는 데 사용되는 채널을 만듭니다.

CreateChannelWithIssuedToken(SecurityToken, EndpointAddress)

지정된 엔드포인트 주소에서 발행된 보안 토큰을 사용하여 서비스에 메시지를 보내는 데 사용되는 채널을 만듭니다.

CreateChannelWithIssuedToken(SecurityToken, EndpointAddress, Uri)

지정된 전송 주소를 통해 특정 엔드포인트 주소에서 발행된 보안 토큰으로 사용할 서비스에 메시지를 보내는 데 사용되는 채널을 만듭니다.

CreateChannelWithOnBehalfOfToken(SecurityToken)

On Behalf Of 보안 토큰을 사용하여 서비스에 메시지를 보내는 데 사용되는 채널을 만듭니다.

CreateChannelWithOnBehalfOfToken(SecurityToken, EndpointAddress)

지정된 엔드포인트 주소에서 On Behalf Of 보안 토큰을 사용하여 서비스에 메시지를 보내는 데 사용되는 채널을 만듭니다.

CreateChannelWithOnBehalfOfToken(SecurityToken, EndpointAddress, Uri)

지정된 전송 주소를 통해 특정 엔드포인트 주소에서 보안 토큰으로 사용할 서비스에 메시지를 보내는 데 사용되는 채널을 만듭니다.

CreateDescription()

서비스 엔드포인트에 대한 설명을 만듭니다.

CreateFactory()

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

(다음에서 상속됨 ChannelFactory)
EndClose(IAsyncResult)

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

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

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

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

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

(다음에서 상속됨 ChannelFactory)
Equals(Object)

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

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

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

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

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

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

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

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

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

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

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

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

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

(다음에서 상속됨 ChannelFactory)
InitializeEndpoint(ServiceEndpoint)

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

(다음에서 상속됨 ChannelFactory)
InitializeEndpoint(String, EndpointAddress)

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

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

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

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

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

(다음에서 상속됨 ChannelFactory)
OnBeginClose(TimeSpan, AsyncCallback, Object)

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

(다음에서 상속됨 ChannelFactory)
OnBeginOpen(TimeSpan, AsyncCallback, Object)

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

(다음에서 상속됨 ChannelFactory)
OnClose(TimeSpan)

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

(다음에서 상속됨 ChannelFactory)
OnClosed()

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

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

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

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

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

(다음에서 상속됨 ChannelFactory)
OnEndOpen(IAsyncResult)

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

(다음에서 상속됨 ChannelFactory)
OnFaulted()

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

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

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

(다음에서 상속됨 ChannelFactory)
OnOpened()

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

(다음에서 상속됨 ChannelFactory)
OnOpening()

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

(다음에서 상속됨 ChannelFactory)
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()

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

(다음에서 상속됨 ChannelFactory)

적용 대상

스레드 보안

이 형식은 스레드로부터 안전합니다.