Share via


HttpServerChannel 클래스

정의

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

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

예제

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

  • 서버

  • 클라이언트

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

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

#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;

int main()
{
   // Create the server channel.
   HttpServerChannel^ serverChannel = gcnew HttpServerChannel( 9090 );
   
   // Register the server channel.
   ChannelServices::RegisterChannel( serverChannel );
   
   // Display the channel's scheme.
   Console::WriteLine( L"The channel scheme is {0}.", serverChannel->ChannelScheme );
   
   // Display the channel's URI.
   Console::WriteLine( L"The channel URI is {0}.", serverChannel->GetChannelUri() );
   
   // Expose an object for remote calls.
   RemotingConfiguration::RegisterWellKnownServiceType(
      RemoteObject::typeid, L"RemoteObject.rem", WellKnownObjectMode::Singleton );
   
   // Get the channel's sink chain.
   IServerChannelSink^ sinkChain = serverChannel->ChannelSinkChain;
   Console::WriteLine( L"The type of the server channel's sink chain is {0}.", sinkChain->GetType() );
   
   // See if the channel wants to listen.
   bool wantsToListen = serverChannel->WantsToListen;
   Console::WriteLine( L"The value of WantsToListen is {0}.", wantsToListen );
   
   // Parse the channel's URI.
   array<String^>^ urls = serverChannel->GetUrlsForUri( L"RemoteObject.rem" );
   if ( urls->Length > 0 )
   {
      String^ objectUrl = urls[ 0 ];
      String^ objectUri;
      String^ channelUri = serverChannel->Parse( objectUrl,  objectUri );
      Console::WriteLine( L"The object URI is {0}.", objectUri );
      Console::WriteLine( L"The channel URI is {0}.", channelUri );
      Console::WriteLine( L"The object URL is {0}.", objectUrl );
   }

   
   // 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);

        // Display the channel's scheme.
        Console.WriteLine("The channel scheme is {0}.",
            serverChannel.ChannelScheme);

        // Display the channel's URI.
        Console.WriteLine("The channel URI is {0}.",
            serverChannel.GetChannelUri());

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

        // Get the channel's sink chain.
        IServerChannelSink sinkChain = serverChannel.ChannelSinkChain;
        Console.WriteLine(
            "The type of the server channel's sink chain is {0}.",
            sinkChain.GetType().ToString());

        // See if the channel wants to listen.
        bool wantsToListen = serverChannel.WantsToListen;
        Console.WriteLine(
            "The value of WantsToListen is {0}.",
            wantsToListen);

        // Parse the channel's URI.
        string[] urls = serverChannel.GetUrlsForUri("RemoteObject.rem");
        if (urls.Length > 0)
        {
            string objectUrl = urls[0];
            string objectUri;
            string channelUri =
                serverChannel.Parse(objectUrl, out objectUri);
            Console.WriteLine("The object URI is {0}.", objectUri);
            Console.WriteLine("The channel URI is {0}.", channelUri);
            Console.WriteLine("The object URL is {0}.", objectUrl);
        }

        // 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^ channel = gcnew HttpClientChannel;
   
   // Register the channel.
   ChannelServices::RegisterChannel( channel );
   
   // Register as client for remote object.
   WellKnownClientTypeEntry^ remoteType = gcnew WellKnownClientTypeEntry(
      RemoteObject::typeid,L"http://localhost:9090/RemoteObject.rem" );
   RemotingConfiguration::RegisterWellKnownClientType( remoteType );
   
   // 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 channel = new HttpClientChannel();

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

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

        // 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 namespace System;
using namespace System::Runtime::Remoting;

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

public:
   int GetCount()
   {
      callCount++;
      return (callCount);
   }

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

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

    public int GetCount()
    {
        callCount++;
        return(callCount);
    }
}

설명

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

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

수행 하려면 추가 서버 쪽에서 메시지의 처리 지정할 수 있습니다 구현의 합니다 IServerChannelSinkProvider 에서 처리 되는 모든 메시지는 HttpServerChannel 전달 됩니다.

HttpServerChannel 이진 또는 SOAP 형식으로 직렬화 하는 메시지를 수락 합니다.

HttpServerChannel 개체에 설정할 수 있는 구성 속성을 연결 된 런타임 구성 파일에서 (정적 호출 하 여 RemotingConfiguration.Configure 메서드) 또는 프로그래밍 방식으로 (전달 하 여를 IDictionary 컬렉션을 HttpServerChannel 생성자)입니다. 목록은 이러한 구성 속성에 대 한 설명서를 참조 하십시오. HttpServerChannel합니다.

생성자

HttpServerChannel()

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

HttpServerChannel(IDictionary, IServerChannelSinkProvider)

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

HttpServerChannel(Int32)

지정된 포트에서 수신하는 HttpServerChannel 클래스의 새 인스턴스를 초기화합니다.

HttpServerChannel(String, Int32)

지정된 이름을 사용하여 특정 포트에서 수신을 대기하는 HttpServerChannel 클래스의 새 인스턴스를 초기화합니다.

HttpServerChannel(String, Int32, IServerChannelSinkProvider)

지정된 이름을 사용하여 특정 포트에서 수신을 대기하며 특정 싱크를 사용하는 HttpServerChannel 특정 포트에 위치한 클래스의 새 인스턴스를 초기화합니다.

필드

SinksWithProperties

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

(다음에서 상속됨 BaseChannelWithProperties)

속성

ChannelData

채널 관련 데이터를 가져옵니다.

ChannelName

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

ChannelPriority

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

ChannelScheme

후크할 수신기의 형식(예: "http")을 가져옵니다.

ChannelSinkChain

현재 채널이 사용하고 있는 채널 싱크 체인을 가져옵니다.

Count

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

(다음에서 상속됨 BaseChannelObjectWithProperties)
IsFixedSize

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

(다음에서 상속됨 BaseChannelObjectWithProperties)
IsReadOnly

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

(다음에서 상속됨 BaseChannelObjectWithProperties)
IsSynchronized

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

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

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

Keys

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

Properties

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

(다음에서 상속됨 BaseChannelWithProperties)
SyncRoot

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

(다음에서 상속됨 BaseChannelObjectWithProperties)
Values

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

(다음에서 상속됨 BaseChannelObjectWithProperties)
WantsToListen

IChannelReceiverHook를 외부 수신기 서비스로 후크해야 하는지 여부를 나타내는 부울 값을 가져옵니다.

메서드

Add(Object, Object)

NotSupportedException를 throw합니다.

(다음에서 상속됨 BaseChannelObjectWithProperties)
AddHookChannelUri(String)

채널 후크가 수신 대기해야 하는 URI를 추가합니다.

Clear()

NotSupportedException를 throw합니다.

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

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

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

NotSupportedException를 throw합니다.

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

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

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

현재 채널의 URI를 반환합니다.

GetEnumerator()

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

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

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

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

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

(다음에서 상속됨 Object)
GetUrlsForUri(String)

현재 HttpChannel에 호스팅된 지정된 URI를 사용하는 개체에 대한 모든 URL 배열을 반환합니다.

MemberwiseClone()

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

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

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

Remove(Object)

NotSupportedException를 throw합니다.

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

현재 채널에게 요청 수신을 시작하도록 지시합니다.

StopListening(Object)

현재 채널에게 요청 수신을 중지하도록 지시합니다.

ToString()

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

(다음에서 상속됨 Object)

명시적 인터페이스 구현

IEnumerable.GetEnumerator()

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

(다음에서 상속됨 BaseChannelObjectWithProperties)

확장 메서드

Cast<TResult>(IEnumerable)

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

OfType<TResult>(IEnumerable)

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

AsParallel(IEnumerable)

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

AsQueryable(IEnumerable)

IEnumerableIQueryable로 변환합니다.

적용 대상

추가 정보