Edit

Kongsi melalui


ServiceHostBase.AddServiceEndpoint Method

Definition

Adds the service endpoints to the service hosted.

Overloads

AddServiceEndpoint(ServiceEndpoint)

Adds the specified service endpoint to the hosted service.

AddServiceEndpoint(String, Binding, String)

Adds a service endpoint to the hosted service with a specified contract, binding, and endpoint address.

AddServiceEndpoint(String, Binding, Uri)

Adds a service endpoint to the hosted service with a specified contract, binding, and a URI that contains the endpoint address.

AddServiceEndpoint(String, Binding, String, Uri)

Adds a service endpoint to the hosted service with a specified contract, binding, endpoint address and URI that contains the address at which it listens.

AddServiceEndpoint(String, Binding, Uri, Uri)

Adds a service endpoint to the hosted service with the specified contract, binding, and URIs that contain the endpoint and listening addresses.

AddServiceEndpoint(ServiceEndpoint)

Adds the specified service endpoint to the hosted service.

public:
 virtual void AddServiceEndpoint(System::ServiceModel::Description::ServiceEndpoint ^ endpoint);
public virtual void AddServiceEndpoint (System.ServiceModel.Description.ServiceEndpoint endpoint);
abstract member AddServiceEndpoint : System.ServiceModel.Description.ServiceEndpoint -> unit
override this.AddServiceEndpoint : System.ServiceModel.Description.ServiceEndpoint -> unit
Public Overridable Sub AddServiceEndpoint (endpoint As ServiceEndpoint)

Parameters

endpoint
ServiceEndpoint

The service endpoint.

Exceptions

Endpoint is null.

The host is not in a Created or an Opening state or there is no ServiceDescription for the hosted service.

The Address, Binding, or Contract property is null.

Remarks

When using the method, the service host does a "by-configuration-name" validation on the contract description. In other words, the host verifies that ConfigurationName exists in the list of configuration names of the service contracts implemented by the service. If the validation passes, the description in the ServiceEndpoint is used as it is, even if the ContractDescription reflected from the service is different.

As an example, assume that the description in the ServiceEndpoint and the contract description reflected from the service have the same name, but different operation behaviors. The implication of only "by-configuration-name" validation is that there is no validation that the behaviors are the same and there are one updates to one description because of another description.

If the address is a relative URI, one of the base addresses of the ServiceHost (depending on the binding protocol) is used as the endpoint's base address.

Applies to

AddServiceEndpoint(String, Binding, String)

Adds a service endpoint to the hosted service with a specified contract, binding, and endpoint address.

public:
 System::ServiceModel::Description::ServiceEndpoint ^ AddServiceEndpoint(System::String ^ implementedContract, System::ServiceModel::Channels::Binding ^ binding, System::String ^ address);
public System.ServiceModel.Description.ServiceEndpoint AddServiceEndpoint (string implementedContract, System.ServiceModel.Channels.Binding binding, string address);
member this.AddServiceEndpoint : string * System.ServiceModel.Channels.Binding * string -> System.ServiceModel.Description.ServiceEndpoint
Public Function AddServiceEndpoint (implementedContract As String, binding As Binding, address As String) As ServiceEndpoint

Parameters

implementedContract
String

The contract implemented by the endpoint.

binding
Binding

The Binding for the endpoint added.

address
String

The address for the endpoint added. This can be an absolute or relative URI. If it is a relative URI, one of the base address of the ServiceHost (depending on the binding protocol) is used as the endpoint's base address.

Returns

The ServiceEndpoint added to the hosted service.

Exceptions

implementedContract or binding or address or is null.

The host is not in a Created or an Opening state or there is no ServiceDescription for the hosted service and so an endpoint cannot be added or the binding lacks a transport of binding scheme.

Examples

  NetTcpBinding portsharingBinding = new NetTcpBinding();
  hostDefault.AddServiceEndpoint(
typeof(CalculatorService),
portsharingBinding,
"net.tcp://localhost/MyService");

Applies to

AddServiceEndpoint(String, Binding, Uri)

Adds a service endpoint to the hosted service with a specified contract, binding, and a URI that contains the endpoint address.

public:
 System::ServiceModel::Description::ServiceEndpoint ^ AddServiceEndpoint(System::String ^ implementedContract, System::ServiceModel::Channels::Binding ^ binding, Uri ^ address);
public System.ServiceModel.Description.ServiceEndpoint AddServiceEndpoint (string implementedContract, System.ServiceModel.Channels.Binding binding, Uri address);
member this.AddServiceEndpoint : string * System.ServiceModel.Channels.Binding * Uri -> System.ServiceModel.Description.ServiceEndpoint
Public Function AddServiceEndpoint (implementedContract As String, binding As Binding, address As Uri) As ServiceEndpoint

Parameters

implementedContract
String

The contract implemented by the endpoint.

binding
Binding

The Binding for the endpoint added.

address
Uri

The Uri that contains the address for the endpoint added. This can be an absolute or relative URI. If it is a relative URI, one of the base address of the ServiceHost (depending on the binding protocol) is used as the endpoint's base address.

Returns

The ServiceEndpoint added to the hosted service.

Exceptions

implementedContract or binding or address or is null.

The host is not in a Created or an Opening state or there is no ServiceDescription for the hosted service and so an endpoint cannot be added.

Applies to

AddServiceEndpoint(String, Binding, String, Uri)

Adds a service endpoint to the hosted service with a specified contract, binding, endpoint address and URI that contains the address at which it listens.

public:
 System::ServiceModel::Description::ServiceEndpoint ^ AddServiceEndpoint(System::String ^ implementedContract, System::ServiceModel::Channels::Binding ^ binding, System::String ^ address, Uri ^ listenUri);
public System.ServiceModel.Description.ServiceEndpoint AddServiceEndpoint (string implementedContract, System.ServiceModel.Channels.Binding binding, string address, Uri listenUri);
member this.AddServiceEndpoint : string * System.ServiceModel.Channels.Binding * string * Uri -> System.ServiceModel.Description.ServiceEndpoint
Public Function AddServiceEndpoint (implementedContract As String, binding As Binding, address As String, listenUri As Uri) As ServiceEndpoint

Parameters

implementedContract
String

The contract implemented by the endpoint.

binding
Binding

The Binding for the endpoint added.

address
String

The address for the endpoint added. This address can be an absolute or relative URI. If it is a relative URI, one of the base address of the ServiceHost (depending on the binding protocol) is used as the endpoint's base address.

listenUri
Uri

The Uri that contains the address which the endpoint listens to for incoming messages. This URI can be relative or absolute.

Returns

The ServiceEndpoint added to the hosted service.

Exceptions

implementedContract or binding or address or is null.

The host is not in a Created or an Opening state or there is no ServiceDescription for the hosted service and so an endpoint cannot be added.

Remarks

If the address is a relative URI, one of the base addresses of the ServiceHost (depending on the binding protocol) is used as the endpoint's base address.

Applies to

AddServiceEndpoint(String, Binding, Uri, Uri)

Adds a service endpoint to the hosted service with the specified contract, binding, and URIs that contain the endpoint and listening addresses.

public:
 System::ServiceModel::Description::ServiceEndpoint ^ AddServiceEndpoint(System::String ^ implementedContract, System::ServiceModel::Channels::Binding ^ binding, Uri ^ address, Uri ^ listenUri);
public System.ServiceModel.Description.ServiceEndpoint AddServiceEndpoint (string implementedContract, System.ServiceModel.Channels.Binding binding, Uri address, Uri listenUri);
member this.AddServiceEndpoint : string * System.ServiceModel.Channels.Binding * Uri * Uri -> System.ServiceModel.Description.ServiceEndpoint
Public Function AddServiceEndpoint (implementedContract As String, binding As Binding, address As Uri, listenUri As Uri) As ServiceEndpoint

Parameters

implementedContract
String

The contract implemented by the endpoint.

binding
Binding

The Binding for the endpoint added.

address
Uri

The Uri that contains the address for the endpoint added. If it is a relative URI, one of the base address of the ServiceHost (depending on the binding protocol) is used as the endpoint's base address.

listenUri
Uri

The Uri that contains the address at which the endpoint listens for incoming messages.

Returns

The ServiceEndpoint added to the hosted service. This URI can be absolute or relative.

Exceptions

implementedContract or binding or address or is null.

The host is not in a Created or an Opening state or there is no ServiceDescription for the hosted service and so an endpoint cannot be added.

Applies to