HttpClientChannel 클래스

정의

HTTP 프로토콜을 사용하여 메시지를 전송하는 원격 호출용 클라이언트 채널을 구현합니다.

public ref class HttpClientChannel : System::Runtime::Remoting::Channels::BaseChannelWithProperties, System::Runtime::Remoting::Channels::IChannelSender
public ref class HttpClientChannel : System::Runtime::Remoting::Channels::BaseChannelWithProperties, System::Runtime::Remoting::Channels::IChannelSender, System::Runtime::Remoting::Channels::ISecurableChannel
public class HttpClientChannel : System.Runtime.Remoting.Channels.BaseChannelWithProperties, System.Runtime.Remoting.Channels.IChannelSender
public class HttpClientChannel : System.Runtime.Remoting.Channels.BaseChannelWithProperties, System.Runtime.Remoting.Channels.IChannelSender, System.Runtime.Remoting.Channels.ISecurableChannel
type HttpClientChannel = class
    inherit BaseChannelWithProperties
    interface IChannelSender
    interface IChannel
type HttpClientChannel = class
    inherit BaseChannelWithProperties
    interface IChannelSender
    interface IChannel
    interface ISecurableChannel
Public Class HttpClientChannel
Inherits BaseChannelWithProperties
Implements IChannelSender
Public Class HttpClientChannel
Inherits BaseChannelWithProperties
Implements IChannelSender, ISecurableChannel
상속
구현

예제

다음 코드 예제를 사용 하는 방법을 보여 줍니다는 HttpClientChannel 원격 서버 및 클라이언트를 설정 합니다. 예제에서는 세 부분이 포함 됩니다.

  • 서버

  • 클라이언트

  • 서버 및 클라이언트에서 사용 하는 원격 개체

다음 코드 예제에서는 서버를 나타냅니다.

#using <System.dll>
#using <System.Runtime.Remoting.dll>
#using "common.dll"
using namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Channels::Http;

void main()
{
   // Create the server channel.
   HttpServerChannel^ serverChannel = gcnew HttpServerChannel( 9090 );
   
   // Register the server channel.
   ChannelServices::RegisterChannel( serverChannel );
   
   // Expose an object for remote calls.
   RemotingConfiguration::RegisterWellKnownServiceType( RemoteObject::typeid, L"RemoteObject.rem", WellKnownObjectMode::Singleton );
   
   // Wait for the user prompt.
   Console::WriteLine( L"Press ENTER to exit the server." );
   Console::ReadLine();
   Console::WriteLine( L"The server is exiting." );
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;

public class Server
{
    public static void Main(string[] args)
    {
        // Create the server channel.
        HttpServerChannel serverChannel = new HttpServerChannel(9090);

        // Register the server channel.
        ChannelServices.RegisterChannel(serverChannel);

        // Expose an object for remote calls.
        RemotingConfiguration.RegisterWellKnownServiceType(
            typeof(RemoteObject), "RemoteObject.rem",
            WellKnownObjectMode.Singleton);

        // Wait for the user prompt.
        Console.WriteLine("Press ENTER to exit the server.");
        Console.ReadLine();
        Console.WriteLine("The server is exiting.");
    }
}

다음 코드 예제에서는이 서버에 대 한 클라이언트를 보여 줍니다.

#using <System.dll>
#using <System.Runtime.Remoting.dll>
#using "common.dll"

using namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Channels::Http;
void main()
{
   // Create the channel.
   HttpClientChannel^ clientChannel = gcnew HttpClientChannel;

   // Register the channel.
   ChannelServices::RegisterChannel( clientChannel );

   // Register as client for remote object.
   WellKnownClientTypeEntry^ remoteType = gcnew WellKnownClientTypeEntry( RemoteObject::typeid,L"http://localhost:9090/RemoteObject.rem" );
   RemotingConfiguration::RegisterWellKnownClientType( remoteType );

   // Create a message sink.
   String^ objectUri;
   System::Runtime::Remoting::Messaging::IMessageSink^ messageSink = clientChannel->CreateMessageSink( L"http://localhost:9090/RemoteObject.rem", nullptr,  objectUri );
   Console::WriteLine( L"The URI of the message sink is {0}.", objectUri );
   if ( messageSink != nullptr )
   {
      Console::WriteLine( L"The type of the message sink is {0}.", messageSink->GetType() );
   }

   // Display the channel's properties using Keys and Item.
   for each(String^ key in clientChannel->Keys)
   {
       Console::WriteLine("clientChannel[{0}] = <{1}>", key, clientChannel[key]);
   }

   // Parse the channel's URI.
   String^ objectUrl = L"http://localhost:9090/RemoteObject.rem";
   String^ channelUri = clientChannel->Parse( objectUrl,  objectUri );
   Console::WriteLine( L"The object URL is {0}.", objectUrl );
   Console::WriteLine( L"The object URI is {0}.", objectUri );
   Console::WriteLine( L"The channel URI is {0}.", channelUri );

   // Create an instance of the remote object.
   RemoteObject^ service = gcnew RemoteObject;
   
   // Invoke a method on the remote object.
   Console::WriteLine( L"The client is invoking the remote object." );
   Console::WriteLine( L"The remote object has been called {0} times.", service->GetCount() );
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;

public class Client
{
    public static void Main(string[] args)
    {
        // Create the channel.
        HttpClientChannel clientChannel = new HttpClientChannel();

        // Register the channel.
        ChannelServices.RegisterChannel(clientChannel);

        // Register as client for remote object.
        WellKnownClientTypeEntry remoteType =
            new WellKnownClientTypeEntry(typeof(RemoteObject),
            "http://localhost:9090/RemoteObject.rem");
        RemotingConfiguration.RegisterWellKnownClientType(remoteType);

        // Create a message sink.
        string objectUri;
        System.Runtime.Remoting.Messaging.IMessageSink messageSink =
            clientChannel.CreateMessageSink(
            "http://localhost:9090/RemoteObject.rem",
            null, out objectUri);
        Console.WriteLine(
            "The URI of the message sink is {0}.",
            objectUri);
        if (messageSink != null)
        {
            Console.WriteLine("The type of the message sink is {0}.",
                messageSink.GetType().ToString());
        }

        // Display the channel's properties using Keys and Item.
        foreach(string key in clientChannel.Keys)
        {
            Console.WriteLine(
                "clientChannel[{0}] = <{1}>",
                key, clientChannel[key]);
        }

        // Parse the channel's URI.
        string objectUrl = "http://localhost:9090/RemoteObject.rem";
        string channelUri = clientChannel.Parse(objectUrl, out objectUri);
        Console.WriteLine("The object URL is {0}.", objectUrl);
        Console.WriteLine("The object URI is {0}.", objectUri);
        Console.WriteLine("The channel URI is {0}.", channelUri);

        // Create an instance of the remote object.
        RemoteObject service = new RemoteObject();

        // Invoke a method on the remote object.
        Console.WriteLine("The client is invoking the remote object.");
        Console.WriteLine("The remote object has been called {0} times.",
            service.GetCount());
    }
}

다음 코드 예제는 서버와 클라이언트에서 사용 하는 원격 개체를 보여 줍니다.

#using <System.dll>
using namespace System;
using namespace System::Runtime::Remoting;

// Remote object.
public ref class RemoteObject: public MarshalByRefObject
{
private:
   static int callCount = 0;

public:
   int GetCount()
   {
      Console::WriteLine( L"GetCount was called." );
      callCount++;
      return (callCount);
   }

};
using System;
using System.Runtime.Remoting;

// Remote object.
public class RemoteObject : MarshalByRefObject
{
    private int callCount = 0;

    public int GetCount()
    {
        Console.WriteLine("GetCount was called.");
        callCount++;
        return(callCount);
    }
}

설명

중요

신뢰할 수 없는 데이터로 이 클래스에서 메서드를 호출하는 것은 보안상 위험합니다. 신뢰할 수 있는 데이터로만 이 클래스에서 메서드를 호출하세요. 자세한 내용은 모든 입력 유효성 검사를 참조하세요.

채널은 원격 경계 (예를 들어, 컴퓨터 또는 애플리케이션 도메인)에서 메시지를 전송합니다. HttpClientChannel 클래스는 HTTP 프로토콜을 사용 하 여 메시지를 전송 합니다.

채널은 원격 호출을 전송 하는.NET Framework remoting 인프라에서 사용 됩니다. 클라이언트가 원격 개체에 대 한 호출 하면 호출 클라이언트 채널에서 전송 및 서버 채널에서 수신 되는 메시지로 serialize 됩니다. 역직렬화하 처리 합니다. 반환 된 값 서버 채널에서 전송 되며 클라이언트 채널에서 수신 됩니다.

수행 하려면 추가 클라이언트 쪽에서 메시지의 처리 지정할 수 있습니다 구현의 합니다 IClientChannelSinkProvider 에서 처리 되는 모든 메시지는 HttpClientChannel 전달 됩니다.

기본적으로 HttpServerChannel SOAP 포맷터를 사용 하 여 모든 메시지를 serialize 합니다.

HttpClientChannel 개체에 설정할 수 있는 구성 속성을 연결 된 런타임 구성 파일에서 (정적 호출 하 여 RemotingConfiguration.Configure 메서드) 또는 프로그래밍 방식으로 (전달 하 여를 IDictionary 컬렉션을 HttpClientChannel 생성자)입니다. 이러한 구성 속성의 목록을 참조 하세요 채널 및 포맷터 구성 속성합니다.

생성자

HttpClientChannel()

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

HttpClientChannel(IDictionary, IClientChannelSinkProvider)

지정된 구성 속성 및 싱크를 사용하여 HttpClientChannel 클래스의 새 인스턴스를 초기화합니다.

HttpClientChannel(String, IClientChannelSinkProvider)

지정된 이름 및 싱크를 사용하여 HttpClientChannel 클래스의 새 인스턴스를 초기화합니다.

필드

SinksWithProperties

채널 싱크 스택 맨 위에 있는 채널 싱크를 나타냅니다.

(다음에서 상속됨 BaseChannelWithProperties)

속성

ChannelName

현재 채널의 이름을 가져옵니다.

ChannelPriority

현재 채널의 우선 순위를 가져옵니다.

Count

채널 개체와 관련된 속성의 수를 가져옵니다.

(다음에서 상속됨 BaseChannelObjectWithProperties)
IsFixedSize

채널 개체에 들어갈 수 있는 속성 수가 고정되었는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 BaseChannelObjectWithProperties)
IsReadOnly

채널 개체에 있는 속성 컬렉션이 읽기 전용인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 BaseChannelObjectWithProperties)
IsSecured

클라이언트 채널이 보안되는지 여부를 가져오거나 설정합니다.

IsSynchronized

채널 개체 속성의 사전이 동기화되었는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 BaseChannelObjectWithProperties)
Item[Object]

지정된 채널 속성을 반환합니다.

Keys

채널 속성과 연결된 키의 ICollection을 가져옵니다.

Properties

현재 채널 개체와 관련된 채널 속성의 IDictionary를 가져옵니다.

(다음에서 상속됨 BaseChannelWithProperties)
SyncRoot

BaseChannelObjectWithProperties에 대한 액세스를 동기화하는 데 사용되는 개체를 가져옵니다.

(다음에서 상속됨 BaseChannelObjectWithProperties)
Values

채널 개체와 관련된 속성 값의 ICollection을 가져옵니다.

(다음에서 상속됨 BaseChannelObjectWithProperties)

메서드

Add(Object, Object)

NotSupportedException를 throw합니다.

(다음에서 상속됨 BaseChannelObjectWithProperties)
Clear()

NotSupportedException를 throw합니다.

(다음에서 상속됨 BaseChannelObjectWithProperties)
Contains(Object)

지정된 키와 관련된 속성이 채널 개체에 포함되어 있는지 여부를 나타내는 값을 반환합니다.

(다음에서 상속됨 BaseChannelObjectWithProperties)
CopyTo(Array, Int32)

NotSupportedException를 throw합니다.

(다음에서 상속됨 BaseChannelObjectWithProperties)
CreateMessageSink(String, Object, String)

지정된 URL이나 채널 데이터 개체에 메시지를 보내는 채널 메시지 싱크를 반환합니다.

Equals(Object)

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

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

채널 개체와 관련된 모든 속성에 대해 열거하는 IDictionaryEnumerator를 반환합니다.

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

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

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

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

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

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

(다음에서 상속됨 Object)
Parse(String, String)

지정된 URL에서 채널 URI와 잘 알려진 원격 개체 URI를 추출합니다.

Remove(Object)

NotSupportedException를 throw합니다.

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

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

(다음에서 상속됨 Object)

명시적 인터페이스 구현

IEnumerable.GetEnumerator()

채널 개체와 관련된 모든 속성에 대해 열거하는 IEnumerator를 반환합니다.

(다음에서 상속됨 BaseChannelObjectWithProperties)

확장 메서드

Cast<TResult>(IEnumerable)

IEnumerable의 요소를 지정된 형식으로 캐스팅합니다.

OfType<TResult>(IEnumerable)

지정된 형식에 따라 IEnumerable의 요소를 필터링합니다.

AsParallel(IEnumerable)

쿼리를 병렬화할 수 있도록 합니다.

AsQueryable(IEnumerable)

IEnumerableIQueryable로 변환합니다.

적용 대상