ServiceDescription.Endpoints 属性

定义

从服务说明获取终结点的集合。

public:
 property System::ServiceModel::Description::ServiceEndpointCollection ^ Endpoints { System::ServiceModel::Description::ServiceEndpointCollection ^ get(); };
public System.ServiceModel.Description.ServiceEndpointCollection Endpoints { get; }
member this.Endpoints : System.ServiceModel.Description.ServiceEndpointCollection
Public ReadOnly Property Endpoints As ServiceEndpointCollection

属性值

ServiceEndpointCollection

包含为服务定义的终结点的 ServiceEndpointCollection

示例

// 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());
    }
}
' 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

注解

此方法所返回的 ServiceEndpointCollection 中的每个终结点都包含有与服务进行通信所需的地址、绑定、协定和行为信息。 若要访问此信息,则您必须利用可使用相关搜索条件的 ServiceEndpoint 方法,在集合中检索 Find。 然后,就可利用 ServiceEndpoint 属性访问该信息了。 例如,可利用 ContractDescription 属性访问 Contract

可通过将 ServiceEndpoint 作为参数传递给 ExportEndpoint(ServiceEndpoint) 来导出服务终结点的元数据。

适用于