ServiceHostBase.AddServiceEndpoint 方法

定義

將服務端點新增至裝載的服務。Adds the service endpoints to the service hosted.

多載

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)

使用指定的合約、繫結以及含有端點位址的 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)

使用指定的合約、繫結、端點位址,以及包含其接聽所在位址的 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)

使用指定的合約、繫結以及含有端點與接聽位址的 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)

參數

endpoint
ServiceEndpoint

服務端點。The service endpoint.

例外狀況

EndpointnullEndpoint is null.

主機的狀態並不是已建立或開啟中,或是裝載之服務沒有任何 ServiceDescriptionThe host is not in a Created or an Opening state or there is no ServiceDescription for the hosted service.

AddressBindingContract 屬性為 nullThe Address, Binding, or Contract property is null.

備註

使用方法時,服務主機會在合約描述上進行「依設定名稱」驗證。When using the method, the service host does a "by-configuration-name" validation on the contract description. 換句話說,主機會驗證 ConfigurationName 服務所執行之服務合約的設定名稱清單中是否存在。In other words, the host verifies that ConfigurationName exists in the list of configuration names of the service contracts implemented by the service. 如果通過驗證,則會使用中的描述 ServiceEndpoint ,就像是 ContractDescription 從服務反映的不同。If the validation passes, the description in the ServiceEndpoint is used as it is, even if the ContractDescription reflected from the service is different.

例如,假設 ServiceEndpoint 中的描述和反映自服務的合約描述具有相同的名稱,但不同的作業行為。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.

如果 address 是相對 URI,則 (的其中一個基底位址(視系結通訊協定而定), ServiceHost) 會當做端點的基底位址使用。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.

適用於

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

參數

implementedContract
String

由端點實作的合約。The contract implemented by the endpoint.

binding
Binding

已新增之端點的 BindingThe Binding for the endpoint added.

address
String

已加入之端點的位址。The address for the endpoint added. 這個位址可以是絕對或相對 URI。This can be an absolute or relative URI. 如果是相對 URI,則 ServiceHost 的其中一個基底位址 (視繫結通訊協定而定) 會當成端點的基底位址使用。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.

傳回

ServiceEndpoint

已新增至裝載之服務的 ServiceEndpointThe ServiceEndpoint added to the hosted service.

例外狀況

implementedContractbindingaddressnullimplementedContract or binding or address or is null.

主機並非處於 CreatedOpening 狀態,或是沒有裝載之服務的 ServiceDescription,因此無法新增端點或繫結缺少繫結配置傳輸。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.

範例

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

適用於

AddServiceEndpoint(String, Binding, Uri)

使用指定的合約、繫結以及含有端點位址的 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

參數

implementedContract
String

由端點實作的合約。The contract implemented by the endpoint.

binding
Binding

已新增之端點的 BindingThe Binding for the endpoint added.

address
Uri

Uri,其中包含已新增之端點的位址。The Uri that contains the address for the endpoint added. 這個位址可以是絕對或相對 URI。This can be an absolute or relative URI. 如果是相對 URI,則 ServiceHost 的其中一個基底位址 (視繫結通訊協定而定) 會當成端點的基底位址使用。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.

傳回

ServiceEndpoint

已新增至裝載之服務的 ServiceEndpointThe ServiceEndpoint added to the hosted service.

例外狀況

implementedContractbindingaddressnullimplementedContract or binding or address or is null.

主機並非處於 CreatedOpening 狀態,或是沒有裝載之服務的 ServiceDescription,因此無法新增端點。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.

適用於

AddServiceEndpoint(String, Binding, String, Uri)

使用指定的合約、繫結、端點位址,以及包含其接聽所在位址的 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

參數

implementedContract
String

由端點實作的合約。The contract implemented by the endpoint.

binding
Binding

已新增之端點的 BindingThe Binding for the endpoint added.

address
String

已加入之端點的位址。The address for the endpoint added. 這個位址可以是絕對或相對 URI。This address can be an absolute or relative URI. 如果是相對 URI,則 ServiceHost 的其中一個基底位址 (視繫結通訊協定而定) 會當成端點的基底位址使用。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

Uri,其中包含端點接聽傳入訊息的所在位址。The Uri that contains the address which the endpoint listens to for incoming messages. 這裡可以使用相對或絕對的 URI。This URI can be relative or absolute.

傳回

ServiceEndpoint

已新增至裝載之服務的 ServiceEndpointThe ServiceEndpoint added to the hosted service.

例外狀況

implementedContractbindingaddressnullimplementedContract or binding or address or is null.

主機並非處於 CreatedOpening 狀態,或是沒有裝載之服務的 ServiceDescription,因此無法新增端點。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.

備註

如果 address 是相對 URI,則 (的其中一個基底位址(視系結通訊協定而定), ServiceHost) 會當做端點的基底位址使用。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.

適用於

AddServiceEndpoint(String, Binding, Uri, 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

參數

implementedContract
String

由端點實作的合約。The contract implemented by the endpoint.

binding
Binding

已新增之端點的 BindingThe Binding for the endpoint added.

address
Uri

Uri,其中包含已新增之端點的位址。The Uri that contains the address for the endpoint added. 如果是相對 URI,則 ServiceHost 的其中一個基底位址 (視繫結通訊協定而定) 會當成端點的基底位址使用。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

Uri,其中包含端點接聽傳入訊息的所在位址。The Uri that contains the address at which the endpoint listens for incoming messages.

傳回

ServiceEndpoint

已新增至裝載之服務的 ServiceEndpointThe ServiceEndpoint added to the hosted service. 這裡可以使用絕對或相對的 URI。This URI can be absolute or relative.

例外狀況

implementedContractbindingaddressnullimplementedContract or binding or address or is null.

主機並非處於 CreatedOpening 狀態,或是沒有裝載之服務的 ServiceDescription,因此無法新增端點。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.

適用於