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

설명

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

채널은 .NET Framework 원격 인프라에서 원격 호출을 전송하는 데 사용됩니다. 클라이언트가 원격 개체를 호출하면 클라이언트 채널에서 보내고 서버 채널에서 수신하는 메시지로 호출이 직렬화됩니다. 그런 다음 역직렬화되고 처리됩니다. 반환된 값은 서버 채널에서 전송되고 클라이언트 채널에서 수신됩니다.

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

HttpServerChannel 진 또는 SOAP 형식으로 serialize된 메시지를 허용합니다.

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

생성자

Name Description
HttpServerChannel()

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

HttpServerChannel(IDictionary, IServerChannelSinkProvider)

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

HttpServerChannel(Int32)

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

HttpServerChannel(String, Int32, IServerChannelSinkProvider)

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

HttpServerChannel(String, Int32)

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

필드

Name Description
SinksWithProperties

채널 싱크 스택의 위쪽 채널 싱크를 나타냅니다.

(다음에서 상속됨 BaseChannelWithProperties)

속성

Name Description
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 나타내는 부울 값을 가져옵니다.

메서드

Name Description
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)

명시적 인터페이스 구현

Name Description
IEnumerable.GetEnumerator()

IEnumerator 채널 개체와 연결된 모든 속성을 열거하는 값을 반환합니다.

(다음에서 상속됨 BaseChannelObjectWithProperties)

확장명 메서드

Name Description
AsParallel(IEnumerable)

쿼리의 병렬 처리를 사용하도록 설정합니다.

AsQueryable(IEnumerable)

IEnumerable IQueryable변환합니다.

Cast<TResult>(IEnumerable)

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

OfType<TResult>(IEnumerable)

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

적용 대상