共用方式為


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,包含為服務定義的端點。

範例

// 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) 的參數,來匯出有關服務端點的中繼資料。

適用於