Прочетете на английски Редактиране

Споделяне чрез


ServiceEndpoint Constructors

Definition

Initializes a new instance of the ServiceEndpoint class.

Overloads

ServiceEndpoint(ContractDescription)

Initializes a new instance of the ServiceEndpoint class for a specified contract.

ServiceEndpoint(ContractDescription, Binding, EndpointAddress)

Initializes a new instance of the ServiceEndpoint class with a specified contract, binding, and address.

ServiceEndpoint(ContractDescription)

Source:
ServiceEndpoint.cs
Source:
ServiceEndpoint.cs

Initializes a new instance of the ServiceEndpoint class for a specified contract.

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

Parameters

contract
ContractDescription

The ContractDescription for the service endpoint.

Examples

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

Remarks

Use this constructor when the binding and address for the endpoint are provided in configuration.

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.NET Core 1.0, Core 1.1, 8 (package-provided), 9 (package-provided), 10 (package-provided)
.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, 4.8.1
.NET Standard 2.0 (package-provided)
UWP 10.0

ServiceEndpoint(ContractDescription, Binding, EndpointAddress)

Source:
ServiceEndpoint.cs
Source:
ServiceEndpoint.cs

Initializes a new instance of the ServiceEndpoint class with a specified contract, binding, and address.

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

Parameters

contract
ContractDescription

The ContractDescription for the service endpoint.

binding
Binding

The Binding that specifies how the service endpoint communicates with the world.

address
EndpointAddress

The EndpointAddress for the service endpoint.

Examples

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

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

Remarks

Use this constructor to specify a service endpoint imperatively in code.

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.NET Core 1.0, Core 1.1, 8 (package-provided), 9 (package-provided), 10 (package-provided)
.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, 4.8.1
.NET Standard 2.0 (package-provided)
UWP 10.0