ServiceDescription 클래스

정의

서비스의 모든 엔드포인트, 해당 주소, 바인딩, 계약 및 동작에 대한 사양 등을 포함하여 메모리에 있는 모든 서비스 설명을 나타냅니다.

public ref class ServiceDescription
public class ServiceDescription
type ServiceDescription = class
Public Class ServiceDescription
상속
ServiceDescription

예제

다음 예제에서는 ServiceDescription 개체를 인스턴스화하는 다양한 방법을 설명합니다.

Uri baseAddress = new Uri("http://localhost:8001/Simple");
ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress);

serviceHost.AddServiceEndpoint(
    typeof(ICalculator),
    new WSHttpBinding(),
    "CalculatorServiceObject");

// Enable Mex
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
serviceHost.Description.Behaviors.Add(smb);

serviceHost.Open();

// Use Default constructor
ServiceDescription sd = new ServiceDescription();

// Create ServiceDescription from a collection of service endpoints
List<ServiceEndpoint> endpoints = new List<ServiceEndpoint>();
ContractDescription conDescr = new ContractDescription("ICalculator");
EndpointAddress endpointAddress = new EndpointAddress("http://localhost:8001/Basic");
ServiceEndpoint ep = new ServiceEndpoint(conDescr, new BasicHttpBinding(), endpointAddress);
endpoints.Add(ep);
ServiceDescription sd2 = new ServiceDescription(endpoints);

// Iterate through the list of behaviors in the ServiceDescription
ServiceDescription svcDesc = serviceHost.Description;
KeyedByTypeCollection<IServiceBehavior> sbCol = svcDesc.Behaviors;
foreach (IServiceBehavior behavior in sbCol)
{
    Console.WriteLine("Behavior: {0}", behavior.ToString());
}

// svcDesc is a ServiceDescription.
svcDesc = serviceHost.Description;
string configName = svcDesc.ConfigurationName;
Console.WriteLine("Configuration name: {0}", configName);

// Iterate through the endpoints contained in the ServiceDescription
ServiceEndpointCollection sec = svcDesc.Endpoints;
foreach (ServiceEndpoint se in sec)
{
    Console.WriteLine("Endpoint:");
    Console.WriteLine("\tAddress: {0}", se.Address.ToString());
    Console.WriteLine("\tBinding: {0}", se.Binding.ToString());
    Console.WriteLine("\tContract: {0}", se.Contract.ToString());
    KeyedByTypeCollection<IEndpointBehavior> behaviors = se.Behaviors;
    foreach (IEndpointBehavior behavior in behaviors)
    {
        Console.WriteLine("Behavior: {0}", behavior.ToString());
    }
}

string name = svcDesc.Name;
Console.WriteLine("Service Description name: {0}", name);

string namespc = svcDesc.Namespace;
Console.WriteLine("Service Description namespace: {0}", namespc);

Type serviceType = svcDesc.ServiceType;
Console.WriteLine("Service Type: {0}", serviceType.ToString());

// Instantiate a service description specifying a service object
// Note: Endpoints collection and other properties will be null since
// we have not specified them
CalculatorService svcObj = new CalculatorService();
ServiceDescription sd3 = ServiceDescription.GetService(svcObj);
String serviceName = sd3.Name;
Console.WriteLine("Service name: {0}", serviceName);
Dim baseAddress As New Uri("http://localhost:8001/Simple")
Dim serviceHost As New ServiceHost(GetType(CalculatorService), baseAddress)

serviceHost.AddServiceEndpoint(GetType(ICalculator), New WSHttpBinding(), "CalculatorServiceObject")

' Enable Mex
Dim smb As New ServiceMetadataBehavior()
smb.HttpGetEnabled = True
serviceHost.Description.Behaviors.Add(smb)

serviceHost.Open()

' Use Default constructor
Dim sd As New ServiceDescription()

' Create ServiceDescription from a collection of service endpoints
Dim endpoints As New List(Of ServiceEndpoint)()
Dim conDescr As New ContractDescription("ICalculator")
Dim endpointAddress As New EndpointAddress("http://localhost:8001/Basic")
Dim ep As New ServiceEndpoint(conDescr, New BasicHttpBinding(), endpointAddress)
endpoints.Add(ep)
Dim sd2 As New ServiceDescription(endpoints)

' Iterate through the list of behaviors in the ServiceDescription
Dim svcDesc As ServiceDescription = serviceHost.Description
Dim sbCol As KeyedByTypeCollection(Of IServiceBehavior) = svcDesc.Behaviors
For Each behavior As IServiceBehavior In sbCol
    Console.WriteLine("Behavior: {0}", CType(behavior, Object).ToString())
Next behavior

' svcDesc is a ServiceDescription.
svcDesc = serviceHost.Description
Dim configName As String = svcDesc.ConfigurationName
Console.WriteLine("Configuration name: {0}", configName)

' Iterate through the endpoints contained in the ServiceDescription
Dim sec As ServiceEndpointCollection = svcDesc.Endpoints
For Each se As ServiceEndpoint In sec
    Console.WriteLine("Endpoint:")
    Console.WriteLine(Constants.vbTab & "Address: {0}", se.Address.ToString())
    Console.WriteLine(Constants.vbTab & "Binding: {0}", se.Binding.ToString())
    Console.WriteLine(Constants.vbTab & "Contract: {0}", se.Contract.ToString())
    Dim behaviors As KeyedByTypeCollection(Of IEndpointBehavior) = se.Behaviors
    For Each behavior As IEndpointBehavior In behaviors
        Console.WriteLine("Behavior: {0}", CType(behavior, Object).ToString())
    Next behavior
Next se

Dim name = svcDesc.Name
Console.WriteLine("Service Description name: {0}", name)

Dim namespc = svcDesc.Namespace
Console.WriteLine("Service Description namespace: {0}", namespc)

Dim serviceType As Type = svcDesc.ServiceType
Console.WriteLine("Service Type: {0}", serviceType.ToString())

' Instantiate a service description specifying a service object
' Note: Endpoints collection and other properties will be null since 
' we have not specified them
Dim svcObj As New CalculatorService()
Dim sd3 As ServiceDescription = ServiceDescription.GetService(svcObj)
Dim serviceName = sd3.Name
Console.WriteLine("Service name: {0}", serviceName)

설명

에 포함 된 정보는 ServiceDescription Windows Communication Foundation (WCF) 시스템 서비스에 대 한 런타임 구성 요소를 작성 하는 데 사용 됩니다.

사용자 지정 동작을 추가하여 ServiceHost를 확장할 때 이 메서드를 사용합니다. Add(T) 개체에서 Behaviors 메서드를 호출하기 전에 Open를 사용하여 ServiceHost에 사용자 지정 서비스 동작을 프로그래밍 방식으로 추가해야 합니다.

합니다 GetService(Object) 하 고 GetService(Type) 메서드를 대체 하는 경우 Windows Communication Foundation (WCF) 프로그래밍 모델을 사용 하 여 동작에 맞게 사용할 수 ServiceHostBase 사용 하 여 사용자의 호스팅 메커니즘입니다.

ServiceEndpointExportEndpoint(ServiceEndpoint)에 매개 변수로 전달하여 서비스 엔드포인트에 대한 메타데이터를 내보냅니다. 이 메서드나 WsdlExporter에서 제공하는 다른 내보내기 메서드 중 하나를 호출한 후 GeneratedWsdlDocuments 속성을 사용하여 ServiceDescription 개체 컬렉션을 반환합니다.

생성자

ServiceDescription()

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

ServiceDescription(IEnumerable<ServiceEndpoint>)

지정한 서비스 엔드포인트 열거형에서 ServiceDescription 클래스의 새 인스턴스를 초기화합니다.

속성

Behaviors

서비스와 연결된 동작을 가져옵니다.

ConfigurationName

<service> 구성 요소의 이름을 가져오거나 설정합니다.

Endpoints

서비스 설명에서 엔드포인트 컬렉션을 가져옵니다.

Name

서비스 이름을 가져오거나 설정합니다.

Namespace

서비스의 네임스페이스를 가져오거나 설정합니다.

ServiceType

서비스의 유형을 가져옵니다.

메서드

Equals(Object)

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

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

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

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

지정한 서비스 개체를 사용하여 초기화되는 서비스 설명을 반환합니다.

GetService(Type)

지정한 서비스 유형을 사용하여 초기화되는 서비스 설명을 반환합니다.

GetType()

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

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

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

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

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

(다음에서 상속됨 Object)

적용 대상