ServiceEndpoint 建構函式

定義

初始化 ServiceEndpoint 類別的新執行個體。

多載

ServiceEndpoint(ContractDescription)

初始化指定合約的 ServiceEndpoint 類別的新執行個體。

ServiceEndpoint(ContractDescription, Binding, EndpointAddress)

使用指定的合約、繫結和位址,初始化 ServiceEndpoint 類別的新執行個體。

ServiceEndpoint(ContractDescription)

初始化指定合約的 ServiceEndpoint 類別的新執行個體。

C#
public ServiceEndpoint (System.ServiceModel.Description.ContractDescription contract);

參數

contract
ContractDescription

服務端點的 ContractDescription

範例

C#
ContractDescription cd = new ContractDescription("Calculator");
ServiceEndpoint svcEndpoint = new ServiceEndpoint(cd);

備註

當組態中提供端點的繫結和位址時,請使用這個建構函式。

適用於

.NET Core 1.1 和其他版本
產品 版本
.NET Core 1.0, Core 1.1
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
UWP 10.0

ServiceEndpoint(ContractDescription, Binding, EndpointAddress)

使用指定的合約、繫結和位址,初始化 ServiceEndpoint 類別的新執行個體。

C#
public ServiceEndpoint (System.ServiceModel.Description.ContractDescription contract, System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress address);

參數

contract
ContractDescription

服務端點的 ContractDescription

binding
Binding

指定服務端點如何與外界溝通的 Binding

address
EndpointAddress

服務端點的 EndpointAddress

範例

C#
string address = "http://localhost:8001/CalculatorService";

ServiceEndpoint endpoint = new ServiceEndpoint(
    ContractDescription.GetContract(
        typeof(ICalculator),
        typeof(CalculatorService)),
        new WSHttpBinding(),
        new EndpointAddress(address));

備註

請使用這個建構函式,以命令方式在程式碼中指定服務端點。

適用於

.NET Core 1.1 和其他版本
產品 版本
.NET Core 1.0, Core 1.1
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
UWP 10.0